From 3e32aea1886b76271865d164fea3a3ecbf07a9f9 Mon Sep 17 00:00:00 2001 From: Sven Schirmer Date: Sat, 11 Nov 2017 08:49:12 +0100 Subject: [PATCH] Accept in ws_connect reuired to actually establish the new connection for the client (see https://stackoverflow.com/questions/41817871/websocket-using-django-channels) --- chat/consumers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chat/consumers.py b/chat/consumers.py index 9a05870..3a72ad4 100644 --- a/chat/consumers.py +++ b/chat/consumers.py @@ -34,6 +34,11 @@ def ws_connect(message): Group('chat-'+label, channel_layer=message.channel_layer).add(message.reply_channel) message.channel_session['room'] = room.label + # in order to establish the connection (as of Django 1.10 or so), it must be accepted + # see https://stackoverflow.com/questions/41817871/websocket-using-django-channels + message.reply_channel.send({ + 'accept': True + }) @channel_session def ws_receive(message):