3

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?
FranXho
  • 736
  • 7
  • 18
  • Websockets are a matter of the OS that the server is running, as well as the browser. If you're running your site on an older server (I'm sure AWS offers older ones and newer), that could explain it. And when I say "older," I mean not much older. In terms of Windows, I don't think Server 2008 R2 even supports them. – Matthew Haugen Jul 18 '14 at 07:33
  • We used Ubuntu 12.04.4 LTS. I think it supports websocket. – FranXho Jul 18 '14 at 07:48
  • Websockets should run in any operating system, it is only a socket service, nothing special. In Windows you can use third party websocket services. – vtortola Jul 18 '14 at 07:53
  • 1
    Are you using an Elastic Load Balancer? Is your application deployed using Elastic Beanstalk? – Michael - sqlbot Jul 18 '14 at 22:53
  • I am not sure about it. May be AWS have elastic load balancer in front of my server. – FranXho Jul 23 '14 at 07:35

3 Answers3

1

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.

DiGiTAL
  • 11
  • 1
1

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

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104
1

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.

Kazaag
  • 2,115
  • 14
  • 14