[Fixed]-Troubleshooting Websockets with EC2 on AWS using Django

2👍

AWS has launched new Application Load Balancer that supports web sockets. Change your ELB to Application Load Balancer and that will fix your issue.

https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer/

2👍

As described here it’s possible to run Django Channels on Elastic Beanstalk using an Application Load Balancer.

In a simplified form, it’s basically:

  1. Create an ALB
  2. Add 2 target groups, one that points to port 80, and one that points to Daphne port, ie 8080.
  3. Create 2 path rules. Let the default route point to target group 1 (port 80), and set the second to use a relative path, ie. /ws/ and point it to target group 2.
  4. Add Daphne and workers to supervisord (or another init system)
  5. DONE! Access Daphne/websockets through the relative url ws://example.com/ws/.
👤ege

0👍

I suppose ALB is the only way. The reason is because with the SSL protocol listner in the classic LB, the session stickiness and X-Forwaded headers won’t be forwarded and will result in the proxy server redirect loop. Doc is here,

http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html

I’ll update the answer if I find out a way with the existing CLB.

👤Babu

Leave a comment