2016-03-01 102 views
0

我有一個的node.js應用服務器運行在80端口和我最近通過Primus WebSockets的變壓器上的端口9001。有沒有人使用Primus websockets支持aws Elastic Load Balancer?

添加實時消息它運作良好,在單個實例。我使用以下配置將消息部署到Beanstalk環境。

AWS Elastic Beanstalk 
Platform version v2.0.0 
Nodejs version v0.12.6 
Primus version v4.0.5 
  • 端口9001被添加到安全組實例的如圖所示的屏幕截圖。 enter image description here
  • 代理服務器在配置選項中設置爲「無」。 enter image description here
  • 在Elastic Load Balancer配置中添加了TCP Listener。 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通信的配置。

回答

0

我設法使用下面的配置在ELB上的端口80和8080上運行websockets(https://github.com/websockets/ws)。那就沒有啓用代理協議。

安全組:

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

0

你需要做兩件事情

增加空閒超時時間上ELB

在EC2儀表板,達到負載均衡器的設置並打開說明標籤爲您的負載平衡器。查找設置「空閒超時」,輸入類似「600」(10分鐘)

平定期

實現一個WS平每隔5分鐘(或其他,但需要比低ELB上的空閒超時)。如果primus不支持其API,請實現自己向客戶端發送虛擬消息。

相關問題