Search code examples
djangowebsocketdjango-channels

'WebSocketProtocol' object has no attribute 'application_queue' error Django Channels


In my Django project I want to create a chat app using channels.But when I followed this tutorial: https://channels.readthedocs.io/en/stable/tutorial/part_2.html , I had a problem that websocket auto disconnect after connect :

 Exception in callback AsyncioSelectorReactor.callLater.<locals>.run()
at
 C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\twisted\internet\asyncioreact
 or.py:287 handle: <TimerHandle when=19405.993
 AsyncioSelectorReactor.callLater.<locals>.run() at
 C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\twisted\interne
 t\asyncioreactor.py:287> Traceback (most recent call last):   File
 "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\asyncio\events.py",
 line 145, in _run
     self._callback(*self._args)   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\twisted\internet\asyncioreactor.py",
 line 290, in run
     f(*args, **kwargs)   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\twisted\internet\tcp.py",
 line 289, in connectionLost
     protocol.connectionLost(reason)   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\autobahn\twisted\websocket.py",
 line 128, in connectionLost
     self._connectionLost(reason)   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\autobahn\websocket\protocol.py",
 line 2467, in _connectionLost
     WebSocketProtocol._connectionLost(self, reason)   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\autobahn\websocket\protocol.py",
 line 1096, in _connectionLost
     self._onClose(self.wasClean, WebSocketProtocol.CLOSE_STATUS_CODE_ABNORMAL_CLOSE, "connection was
 closed uncleanly (%s)" % self.wasNotCleanReason)   File
 "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\autobahn\twisted\websocket.py",
 line 171, in _onClose
     self.onClose(wasClean, code, reason)   File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\daphne\ws_protocol.py",
 line 146, in onClose
     self.application_queue.put_nowait({ AttributeError: 'WebSocketProtocol' object has no attribute 'application_queue'

Solution

  • Above this error should be a list of paths and at the top of that paths are the real error. In my case it was the routing url.