Troubleshooting Websockets with EC2 on AWS using Django

前端 未结 3 525
清酒与你
清酒与你 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/.

提交回复
热议问题