django-channels 2.0 websocket connection problem (error 500)

879 views
Skip to first unread message

Alberto Buratti

unread,
Feb 5, 2018, 12:40:19 PM2/5/18
to Django users
Hello,
I've just installed django-channels 2 and followed the installation instructions. I've got this error while trying to connect a websocket to my application:

Browser console:
websocketbridge.js:118 WebSocket connection to 'ws://127.0.0.1:8000/userlocation/' failed: Error during WebSocket handshake: Unexpected response code: 500

Django runserver:
[2018/02/05 18:12:56] WebSocket HANDSHAKING /userlocation/ [127.0.0.1:36137]
[2018/02/05 18:12:57] WebSocket DISCONNECT /userlocation/ [127.0.0.1:36137]

I cannot make the output more verbose (already running with -v 3).


consumers.py
from channels.generic.websocket import JsonWebsocketConsumer


class UserLocationConsumer(JsonWebsocketConsumer):
def receive_json(self, content, **kwargs):
print(content)

routing.py
from django.urls import path
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from mobile.consumers import UserLocationConsumer

application = ProtocolTypeRouter({
"websocket": AuthMiddlewareStack(
URLRouter([
path('userlocation/', UserLocationConsumer),
]))
,
})


Running on ubuntu 16.04 with python 3.5.2, Django 2.0.2
Am I missing something?



Andrew Godwin

unread,
Feb 5, 2018, 1:42:18 PM2/5/18
to django...@googlegroups.com
Have you upgraded to the most recent version of Daphne? There was a bug where tracebacks weren't printing sometimes that I fixed over the weekend.

Andrew

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/46ab0475-da21-4e53-9da7-3e3e4036134a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages