Troubleshooting Websockets with EC2 on AWS using Django

前端 未结 3 498
清酒与你
清酒与你 2020-12-30 07:04

I am using Django-Channels to try to get real time features such as chat/messaging, notifications, etc. Right now, I have gotten everything to work fine on my laptop using t

相关标签:
3条回答
  • 2020-12-30 07:20

    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/.
    0 讨论(0)
  • 2020-12-30 07:25

    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.

    0 讨论(0)
  • 2020-12-30 07:38

    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/

    0 讨论(0)
提交回复
热议问题