FranXho
FranXho

Reputation: 765

Why websocket don't work on the cloud?

I developed our websocket project on wildfly. When we test it on localhost or within our local network, everything work fine. But when I deployed it on AWS, websocket don't work any longer. We can access other html pages. But when we conenct to "ws://ip/project location ", chrome just says hand shake error. I have experienced the same web socket problem on jelastic hosting too. My question is

  1. Why it is happening like this?
  2. Is websocket protocol not stable enough?
  3. Is there any suitable hosting for websocket projects in java?

Upvotes: 3

Views: 2566

Answers (3)

Kazaag
Kazaag

Reputation: 2145

Currently ELB doesn't support Websocket in HTTP mode. To be able to handle Websocket you need to configure the ELB in tcp mode (the payload of the tcp connection will be send directly to the server, so the ELB doesn't impact the http and ws flow). With this set up you won't be able to see the caller ip.

Without the ELB Websocket works perfectly (AWS only sees ip traffic and the OS only tcp one), we haven't change any thing for a plain old http server in order to use WS (except the WS handling code in the web server).

To know if you are using ELB look at the bill, AWS can provide you a lot of very interesting services, for a fee.

Upvotes: 1

Scott Stensland
Scott Stensland

Reputation: 28285

I suggest you try deploying to the cloud provider : Heroku - their sample app code using node.js and websockets will get you up and running quickly. A locally running websocket app which uses a specific port - say 8888 will run fine on heroku with :

var port = process.env.PORT || 8888;

as heroku internally will deploy your app with a run-time generated port visible via PORT . If you are using node.js with websockets I suggest using the einaros ws implementation

var WebSocketServer = require("ws").Server;

which seamlessly handles the notion of ws port -vs- the http port

Upvotes: 1

DiGiTAL
DiGiTAL

Reputation: 11

So far balancers don't forward websocket headers. To make WS working you must have a public IP address and no other services in front of your application.

Upvotes: 1

Related Questions