有没有人使用Primus和aws Elastic Load Balancer后面的websockets?

时间:2016-03-01 03:13:08

标签: node.js websocket elastic-beanstalk primus

我有一个在端口80上运行的node.js应用服务器,我最近通过端口9001上的Primus websockets转换器添加了实时消息。

它在单个实例中运行良好。我使用以下配置将消息传递部署到Beanstalk环境。

AWS Elastic Beanstalk
Platform version v2.0.0
Nodejs version v0.12.6
Primus version v4.0.5
  • 端口9001被添加到实例的安全组中,如屏幕截图所示。 enter image description here
  • 配置选项中的代理服务器设置为“none”。 enter image description here
  • 在Elastic Load Balancer配置中添加了TCP侦听器。 enter image description here
  • aws documentation中所述启用代理协议。 enter image description here enter image description here enter image description here
  • 在primus服务器配置中添加了proxywrap。

但客户端请求未到达实例并且连接超时。有没有人在AWS ELB后面使用带有websockets的primus? 请让我知道在Elastic Beanstalk背后启用websockets通信的配置。

2 个答案:

答案 0 :(得分:0)

我设法使用下面的配置使用websocket(https://github.com/websockets/ws)在ELB上的端口80和8080上工作。并且没有启用代理协议。

安全组:

https://cloud.githubusercontent.com/assets/3421858/14969922/ff6659f4-10bc-11e6-903c-168a530efebd.png

负载均衡器监听器:

https://cloud.githubusercontent.com/assets/3421858/14969937/160c7544-10bd-11e6-8357-a11f5481d9fd.png

容器选项:

https://cloud.githubusercontent.com/assets/3421858/14969950/38776f1c-10bd-11e6-961b-aabbf0ab1d66.png

负载均衡器:

https://cloud.githubusercontent.com/assets/3421858/14969983/6c4f47ce-10bd-11e6-8fa0-eb8180ffb281.png

答案 1 :(得分:0)

你需要做两件事

增加ELB上的空闲超时

在EC2仪表板上,触及Load Balancer设置并打开负载均衡器的“描述”选项卡。查找设置“空闲超时”,输入类似“600”(10分钟)的内容

定期Ping

每5分钟(或其他,但需要低于ELB上的空闲超时)实施WS ping。如果primus对其API没有支持,请自己向客户端发送虚拟消息。

相关问题