Skip to content Skip to sidebar Skip to footer

Websocket Disconnect Received Unexpectedly By Using Django Channels

Using Django channels to update the user on the current status of a potentially long running task, I'm facing a WebSocket DISCONNECT that I would like to trace down. The setup look

Solution 1:

That consumer is trying to send a message before accepting the connection.

I just tested and Daphne throws this exception:

 File "...site-packages/daphne/ws_protocol.py", line 193, in handle_reply
 "Socket has not been accepted, so cannot send over it"

And the clients receive a CloseEvent with code 1006

Solution 2:

This looks like the same problem I described here.

Last message of your server before disconnect is that it is trying to send something (large?). I discovered that sending large WebSocket messages may lead to disconnect with error 1006.

You may try to configure your WebSocket server to send data in small chunks. It helped in my case.

Post a Comment for "Websocket Disconnect Received Unexpectedly By Using Django Channels"