在过去的2天里,我一直在尝试让我的Django Channels应用在Heroku上运行,但似乎无法让它工作。最近,我甚至无法运行该应用程序,但经过一些调查,我设法启动它。该应用程序在本地主机上运行良好。我从有错误404,到500,现在504。我一直在尝试了解Heroku日志,但似乎找不到解决方案。希望有人能给我一个提示,如何解决它.这里是不同的文件和日志。
设置。
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
},
},
}
要求:
Django==3.0.7
gunicorn==19.9.0
pytz==2019.3
sqlparse==0.3.0
whitenoise==5.0.1
tweepy==3.8.0
dj-database-url==0.5.0
psycopg2-binary==2.8.5
discord.py==1.3.3
requests==2.23.0
channels-redis==2.4.2
channels==2.4.0
daphne==2.5.0
asgi.py
import os
import django
from channels.routing import get_default_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'APPNAME.settings')
django.setup()
application = get_default_application()
Procfile:
web: daphne APPNAME.asgi:application --port $PORT --bind 0.0.0.0 -v2
Heroku日志。
2020-06-09T14:57:15.403840+00:00 app[web.1]: 2020-06-09 14:57:15,403 DEBUG HTTP response complete for ['10.38.205.57', 33999]
2020-06-09T14:57:15.403926+00:00 app[web.1]: 10.38.205.57:33999 - - [09/Jun/2020:14:57:15] "GET /static/img/favicon.png" 200 10836
2020-06-09T14:57:15.400849+00:00 heroku[router]: at=info method=GET path="/static/img/favicon.png" host=www.domain.com request_id=fe8bd6bb-9050-4815-bf83-0b65cdb0b0cf fwd="90.90.83.191" dyno=web.1 connect=0ms service=7ms status=200 bytes=11090 protocol=https
2020-06-09T14:57:15.567171+00:00 app[web.1]: 2020-06-09 14:57:15,566 ERROR [Failure instance: Traceback: <class 'ValueError'>: No route found for path 'ws/panel/order/96eda/'.
2020-06-09T14:57:15.567180+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/autobahn/websocket/protocol.py:2847:processHandshake
2020-06-09T14:57:15.567181+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/txaio/tx.py:366:as_future
2020-06-09T14:57:15.567182+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/twisted/internet/defer.py:151:maybeDeferred
2020-06-09T14:57:15.567182+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/daphne/ws_protocol.py:83:onConnect
2020-06-09T14:57:15.567183+00:00 app[web.1]: --- <exception caught here> ---
2020-06-09T14:57:15.567183+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/twisted/internet/defer.py:151:maybeDeferred
2020-06-09T14:57:15.567183+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/daphne/server.py:200:create_application
2020-06-09T14:57:15.567184+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/channels/routing.py:54:__call__
2020-06-09T14:57:15.567184+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/channels/sessions.py:47:__call__
2020-06-09T14:57:15.567185+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/channels/sessions.py:145:__call__
2020-06-09T14:57:15.567185+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/channels/sessions.py:169:__init__
2020-06-09T14:57:15.567185+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/channels/middleware.py:31:__call__
2020-06-09T14:57:15.567186+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/channels/routing.py:150:__call__
2020-06-09T14:57:15.567258+00:00 app[web.1]: ]
2020-06-09T14:57:15.567533+00:00 app[web.1]: 2020-06-09 14:57:15,567 DEBUG Upgraded connection ['10.15.161.126', 32805] to WebSocket
2020-06-09T14:57:19.879740+00:00 app[web.1]: 2020-06-09 14:57:19,879 WARNING dropping connection to peer tcp4:10.15.161.126:32805 with abort=True: WebSocket opening handshake timeout (peer did not finish the opening handshake in time)
2020-06-09T14:57:19.880267+00:00 app[web.1]: 2020-06-09 14:57:19,880 DEBUG WebSocket closed for ['10.15.161.126', 32805]
2020-06-09T14:57:19.880376+00:00 app[web.1]: 10.15.161.126:32805 - - [09/Jun/2020:14:57:19] "WSDISCONNECT /ws/panel/order/96eda/" - -
2020-06-09T14:57:19.880503+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/ws/panel/order/96eda/" host=www.domain.com request_id=7b5b433b-c291-4994-8b5b-8e424447ce3e fwd="90.90.83.191" dyno=web.1 connect=0ms service=4319ms status=503 bytes=0 protocol=https
2020-06-09T14:56:44+00:00 app[heroku-redis]: source=REDIS addon=redis-cubed-69516 sample#active-connections=1 sample#load-avg-1m=0.165 sample#load-avg-5m=0.17 sample#load-avg-15m=0.155 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15664256kB sample#memory-free=11266544kB sample#memory-cached=1033556kB sample#memory-redis=313968bytes sample#hit-rate=1 sample#evicted-keys=0
先谢谢你了。
发现我的错误,是最愚蠢的错误。错误是在我的路由,输入 "wsspanelorder "以为wss部分是我的协议。