channels: 503 in the middle of long requests
If you’re submitting a bug report, please include:
- Your OS and runtime environment, and browser if applicable
- The versions of Channels, Daphne, Django, Twisted, and your ASGI backend (asgi_ipc or asgi_redis normally)
- What you expected to happen vs. what actually happened
- How you’re running Channels (runserver? daphne/runworker? Nginx/Apache in front?)
- Console logs and full tracebacks of any errors
OS: Mac OS Sierra Browser: Google Chrome Channels: 1.1.6 daphne: 1.3.0 Twisted: 17.5.0 Django: 1.11.5 ASGI Backend: asgi_redis
Running channels from just runserver, heres my redis config:
REDIS_HOST = os.environ['REDIS_HOST'] if 'REDIS_HOST' in os.environ else 'localhost'
REDIS_PORT = os.environ['REDIS_PORT'] if 'REDIS_PORT' in os.environ else 6379
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [(REDIS_HOST, REDIS_PORT)],
},
"ROUTING": "helloDeploy.routing.channel_routing",
},
}
so on long requests, django returns a 503 to the frontend in the middle of the request. If I set a breakpoint somewhere, then leave the breakpoint running, then a 503 is returned. I’m fairly sure that this is caused by channels somehow as this has never happened before. Anybody have any insight here?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 28 (14 by maintainers)
So Django has its own http_timeout arg. Will setting this also set it for Daphne? If not, how would I set it for Daphne as I’m using the
python manage.py runserver
command?EDIT: Nevermind, I see this here
So for anyone who comes across this, just run
Aha, yes, that’s it. I didn’t twig that this was a websocket working perfectly for 60 seconds and then getting a 503 sent to it. Fixing it.
This should be fixed by https://github.com/django/daphne/commit/105e1d5436f007acfadfd669c2b4550ae8faf32d. I’ll do a daphne release momentarily.
I have the same problem with this simple echo consumer:
and this in a browser:
Started with “runserver -v 2”, the output is:
Somehow the “http_protocol” seems to thinks its still responsible for the connection and closes it after a timeout, i think here: https://github.com/django/daphne/blob/3b2fb6f78e7bbee887663cb64e81e735b09134ee/daphne/http_protocol.py#L236-L242
The
Invalid frame header
is simply because daphne responds with http while the browser expects websocket. Wireshark capture:Maybe because what is stated in this comment line here looks like its never actually done? I see no code to remove the “reply channel association” after this comment https://github.com/django/daphne/blob/3b2fb6f78e7bbee887663cb64e81e735b09134ee/daphne/http_protocol.py#L119
Is there a backwards-compatible fix for 1.X here? I am seeing the same error there. (NB: obviously we’d love to upgrade, but we utterly failed at accounting for performance when trying it previously)
Tested and confirmed. No time out errors (503) with your latest commit.