亚马逊ec2上的Websockets连接失败

use*_*427 12 amazon-ec2 websocket atmosphere netty

我有一个运行大气框架的netty服务器,用于通过websockets实时通知系统.

该系统在我的本地机器上运行完美,但是当我在EC2上部署时,它似乎不起作用.我可以telnet到远程Netty服务器.可以访问服务器并在EC2上打开端口

Firefox抛出以下错误

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).
Run Code Online (Sandbox Code Playgroud)

服务器甚至没有得到请求,这让我觉得这是一些我不知道的EC2网络套接字问题.

moo*_*odh 7

你在使用ELB吗?如果是,则需要切换到TPC而不是HTTP,因为HTTP层不支持websockets.在运行TCP时,您将失去粘性和检索客户端IP的可能性,但Websockets将一直工作.=)

有关EC2/ELB/Websockets的更多信息:
http://johan.firebase.co/post/31047804966/the-state-of-websockets-ssl-and-sticky-sessions-in
http://johan.heapsource.com/ post/31047804966/the-state-of-websockets-ssl-and-sticky-sessions-in https://web.archive.org/web/20160328183724/http://johan.heapsource.com/post/31047804966/the -state-的-的WebSockets-SSL-和粘性会话

  • http://johan.heapsource.com/post/31047804966/the-state-of-websockets-ssl-and-sticky-sessions-in (2认同)

小智 5

我在php中遇到了同样的问题。解决方案是:使用您private ip的EC2地址创建websocket 。并使用您的EC2公共IP地址或带有Web套接字端口的url连接该Websocket

您将收到EC2 Web套接字的响应


Rog*_*ger -1

使用 nc(命令行 linux / OSX),您可以轻松检查端口是否已启动并正在运行。

nc -z www.google.com 80
Run Code Online (Sandbox Code Playgroud)

如果没有,请检查您的安全组。登录EC2:

在网络和安全下左侧:选择安全组 -> 打开默认值 -> 入站。您可以在那里创建新规则。