Skanda
Skanda

Reputation: 882

Has anyone used Primus with websockets behind aws Elastic Load Balancer?

I have a node.js application server running on port 80 and I recently added realtime messaging through Primus websockets transformer on port 9001.

It works well in single instance. I deployed the messaging to Beanstalk environment with the following configuration.

AWS Elastic Beanstalk
Platform version v2.0.0
Nodejs version v0.12.6
Primus version v4.0.5

But the client requests doesn't reach the instance and connection timed out. Has anyone used primus with websockets behind AWS ELB? Please let me know the configuration which enables websockets communication behind Elastic Beanstalk.

Upvotes: 0

Views: 406

Answers (2)

André Werlang
André Werlang

Reputation: 5944

You need to do two things

Increase idle timeout on ELB

On EC2 dashboard, reach for Load Balancer settings and open the Description tab for your load balancer. Look for the setting "Idle timeout", type something like "600" (for 10 minutes)

Ping periodically

Implement a WS ping every 5 minutes (or other, but need to be lower than the idle timeout on ELB). If primus doesn't have support on its API, implement yourself sending of a dummy message to client.

Upvotes: 0

codepreneur
codepreneur

Reputation: 466

I managed to get websockets (https://github.com/websockets/ws) working on both port 80 and 8080 on ELB with the configurations below. And thats without enabling Proxy-Protocol.

Security group:

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

Load balancer listeners:

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

Container options:

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

Load balancer:

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

Upvotes: 2

Related Questions