-
Hey all, Running channels 3.0.4, Django 3.2. Just switched production from Daphne to guincorn with uvicorn workers (as advised here) on Heroku. So basically up until I had this in my Procfile:
So far it's nice to squeeze a bit more from the server, however on the sockets layer I'm getting these exceptions whenever a websocket is closed. I'm assuming this is because both uvicorn and channels are attempting to close the websocket or something? Here are the logs and the consumer's source code follows: Logs
Consumer (relevant code)
I left the Or am I missing something entirely different here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
What happens if you put logging in (A.k.a Can you reduce it or dig some more? — There could be anything going on from what you've put, so investigation needed.) |
Beta Was this translation helpful? Give feedback.
So I think I found the root cause, I think.
The
websockets
library (utilized byasyncio
, utilized byuvicorn
) closes the websocket here:https://github.com/python-websockets/websockets/blob/fe629dede6eb083013e0d2373d5c3120c0078db3/src/websockets/legacy/server.py#L257-L265
...and only then Channels
disconnect()
method is being called. By the timedisconnect()
is called, the websocket is already closed, so when we callself.close()
- we get the exception.So now the question is (@carltongibson if you can chime in that'd be great):
Is this expected? is it problematic can I safely remove
self.close()
fromdisconnect()
?How do we deal with this if at all? it seems a bit limiting that
disconnect()