Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websockets connection failure on amazon ec2

I have a netty server running the atmosphere framework for a real-time notification system over websockets.

The system works perfectly on my local machine, but when I deploy it on EC2, It just does not seem to work. I am able to telnet to the remote Netty server though. The server is accessible and ports are open on EC2

Firefox throws the following error

Using URL: ws://beta.myapp.com:2880/myhandle?id=1&name=Chinese_food_rule_2&    X-Atmosphere-tracking-id=35490c47-59d6-abf6-36fa-431aa340d90a&X-Atmosphere-Framework=0.9&X-Atmosphere-Transport=websocket&X-Cache-Date=0&Content-Type=application/json

Websocket error, reason: undefined

Firefox can't establish a connection to the server at ws://beta.myapp.com:2880/myhandle?id=1&name=Chinese_food_rule_2&X-Atmosphere-tracking-id=35490c47-59d6-abf6-36fa-431aa340d90a&X-Atmosphere-Framework=0.9&X-Atmosphere-Transport=websocket&X-Cache-Date=0&Content-Type=application/json.

Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).

The server does not even get a request, this leads me to think that this is some EC2 web sockets gotcha which I am not aware of.

like image 511
user371427 Avatar asked Aug 06 '12 10:08

user371427


People also ask

Does AWS support WebSocket?

A WebSocket API in API Gateway is a collection of WebSocket routes that are integrated with backend HTTP endpoints, Lambda functions, or other AWS services. You can use API Gateway features to help you with all aspects of the API lifecycle, from creation through monitoring your production APIs.

How do I enable WebSocket connections?

- In Control Panel, click Programs and Features, and then click Turn Windows features on or off. Expand Internet Information Services, expand World Wide Web Services, expand Application Development Features, and then select WebSocket Protocol. Click OK. Click Close.


1 Answers

I got this same issue in php. The solution is: create websocket using your private ip address of EC2. and connect that websocket using your EC2 public ip address or url with web socket port

you will get response from EC2 web socket

like image 193
ABIRAMAN Avatar answered Sep 20 '22 15:09

ABIRAMAN