[英]django channels on aws : daphne and workers running but websocket taret unhealthy
使我的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。
我的supervisor.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狀態的結果時,它表明它們運行良好。 但我仍然得到404的ws響應。
請幫助,讓我知道是否需要更多信息。
項目是否在本地運行? 如果不是,則問題出在軟件上。 如果是這樣,則問題出在您的部署上。 我將檢查安全組/防火牆/ ELB配置,以確保可以訪問正確的端口。
只要您實際部署了Redis后端(沒有提供信息),就不必在每個實例上本地運行Redis后端。 Redis是一個緩存系統,允許通過不同實例共享數據。 從體系結構的角度來看,更接近於DB的是一個簡單的守護進程線程。 您應該改用外部Redis緩存,並在Django conf上引用它。
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"ROUTING": "<YOUR_APP>.routing.application",
"CONFIG": {
"hosts": ["redis://"+REDIS_URL+":6379"],
},
},
}
請參閱AWS ElasticCache服務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.