我一直在关注这篇文章 - https://blog.mangoforbreakfast.com/2017/02/13/django-channels-on-aws-elastic-beanstalk-using-an-alb/
让我的 django-channels 应用程序在 aws 上运行 ..但只有非 websockets 请求得到处理。
我的频道层设置是:
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
},
"ROUTING": "malang.routing.channel_routing",
},
}
正如文章中提到的,我有两个目标群体。一条转发路径 / 到端口 80 和 /ws/* 到 5000。
我的 supervisord.conf 是 -
[program:Daphne]
environment=PATH="/opt/python/run/venv/bin"
command=/opt/python/run/venv/bin/daphne -b 0.0.0.0 -p 5000
malang.asgi:channel_layer
directory=/opt/python/current/app
autostart=true
autorestart=true
redirect_stderr=true
user=root
stdout_logfile=/tmp/daphne.out.log
[program:Worker]
environment=PATH="/opt/python/run/venv/bin"
command= /opt/python/run/venv/bin/python manage.py runworker
directory=/opt/python/current/app
process_name=%(program_name)s_%(process_num)02d
numprocs=4
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/tmp/workers.out.log
当我在 aws 日志上检查 supervisorctl status 的结果时,它显示它们运行良好。但我仍然得到 ws 的 404 响应。
如果您需要更多信息,请帮助并告诉我。