2

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'
7
  • Hi, were you able to solve this? Commented May 2, 2018 at 13:28
  • No, I weren't. :( Commented May 3, 2018 at 4:27
  • I've fixed it. 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. Commented May 3, 2018 at 6:34
  • @EduardAlbu could you post your solution please? Commented May 3, 2018 at 6:40
  • I've fixed it. Follow @EduardAlbu in my case it wasn't migrate. Commented May 3, 2018 at 7:52

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Are you guys kidding? Anyone reading this question and answer will never know what was the problem. And the answer is like, "Go to the doctor, find your problem, good luck!!"
1

migration solve it for me

python manage.py migrate

Comments

0

Just to clarify this error for everyone who faces it while following the channels tutorial for me the error was in my path

2018-05-17 15:55:36,382 - ERROR - ws_protocol - [Failure instance: Traceback: : No route found for path 'ws/chat/me/'.

You can find it on top of the stacktrace

My defined invalid URL pattern "buzz" because I like to change things up. Essentially it works the same way as django url patterns so just need to make sure that your routing structure matches what you specify.

websocket_urlpatterns = [
    url(r'^ws/buzz/(?P<room_name>[^/]+)/$', consumers.ChatConsumer),
]

In my case the route path did not match my websocket patterns I had to update the route path to be correct -> by changing my websocket_urlpatterns back to chat

websocket_urlpatterns = [
    url(r'^ws/chat/(?P<room_name>[^/]+)/$', consumers.ChatConsumer),
]

So the system could resolve my issue. Hopefully it helps people who run into this in the future. Good luck. P.T.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.