primus / primus

:zap: Primus, the creator god of the transformers & an abstraction layer for real-time to prevent module lock-in.
MIT License
4.47k stars 271 forks source link

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

Open manikandants opened 8 years ago

manikandants commented 8 years ago

Version: 4.0.5

Environment: AWS Elasticbeanstalk

Expected result:

Actual result:

Steps to reproduce: I have a node.js application server and I recently added realtime messaging through Primus websockets transformer. It works well in single instance. I deployed the messaging to production environment (AWS Elastic beanstalk) and added websocket port to security group. But the client requests doesn't reach the instance. Has anyone used primus with websockets behind AWS ELB? Please let me know what needs to be done to enable the communication

lpinca commented 8 years ago

AFAIK, AWS ELB does not support WebSocket.

manikandants commented 8 years ago

Thanks @lpinca That's a bad news for me :( How is the support for any other transformers like Socket.io/Sockjs/Engine.io?

lpinca commented 8 years ago

It might work but you'll be limited to the polling transports. Take a look at this old issue https://github.com/primus/primus/issues/87.

manikandants commented 8 years ago

Thanks for the info. I'm trying out the proxywrap module. I'll explore and update on the issue.

ddennis commented 8 years ago

So i might be misunderstanding the issue, sorry if i am way off.

But I have been running the WS module on Elastic Beanstalk with Primus in production for over a year, without any problems. Using the node cluster module to scale out and ELB to handle https.

Have you tried setting the proxy server to "none": On Elastic Beanstalk goto Configuration > Software Configuration > Container Options: set Proxy server: none.

By the way i have had problems installing the ws module on newer version of node on Elastic Beanstalk, so i would recommend staying on node 0.12.6 and ELB node v2.0.8

manikandants commented 8 years ago

@ddennis My proxy server is set to "none" in container options. I am still on ELB v2.0.0 running nodejs 0.12.6. Have you enabled proxy-protocol as mentioned in aws documentation? What is the listener configuration and security group configuration that is working for you? I have application server running on port 80 and websockets running on port 9001. I have opened both ports in security group, added TCP listener for port 9001, enabled proxy protocol as mentioned in the link above and included proxywrap as well. But still client is not able to connect to websocket. I probably am missing some silly thing. but couldn't figure out the same.

manikandants commented 8 years ago

You can find my configuration with screenshots in stackoverflow

ddennis commented 8 years ago

@manikandants I have not enabled the proxy-protocol, or included proxywrap.

Configuration > Software Configuration > Container Options config

TCP Listener is added in the Elastic Load Balancer configuration. lb

security group of the instance inbound

manikandants commented 8 years ago

Thanks. I'll disable proxy and try it.

lpinca commented 8 years ago

Thank you for the help @ddennis. @manikandants any luck so far?

manikandants commented 8 years ago

Nope. The requests are reaching the loadbalancer, but not the ec2 instances behind it. We have temporarily created an ec2 instance just to handle messaging, along with the load balanced application server until we figure out the issue/our userbase get big enough to overload the ec2 instance.

codepreneur commented 8 years ago

@manikandants I managed to get websockets (https://github.com/websockets/ws) working on both port 80 and 8080 on ELB with the configurations below.

Security group:

image

Load balancer listeners:

image

Container options:

image

Load balancer:

image

alka-axonic commented 8 years ago

Hello, i have same Problem. Wir have nodejs App with Primus. If I try to make tcp connection over Port 80 and 443 works sockets but the page dies not work. If I try to make the connection over https work the page, but sockets does no work. I try to activate Proxy protocol, does not help. Has anyone ideas?

djamalouch commented 6 years ago

AWS now seems to support Websockets: https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer/