farmillion123
farmillion123

Reputation: 169

WebSocket connection to 'ws:url' failed: WebSocket is closed before the connection is established

I am pretty new to Django Channels and when i went through some tutorials i came across this project Channels Examples.When i run the project in my system, i get the following error.

127.0.0.1:56653 - - [20/Feb/2018:17:18:37] "GET /new/" 302 -
127.0.0.1:56653 - - [20/Feb/2018:17:18:38] "GET /royal-dawn-8676/" 200 1865
127.0.0.1:56653 - - [20/Feb/2018:17:18:38] "GET /static/chat.js" 304 -
127.0.0.1:56669 - - [20/Feb/2018:17:18:38] "WSCONNECTING /chat/royal-dawn-8676/" - -
127.0.0.1:56669 - - [20/Feb/2018:17:18:40] "WSDISCONNECT /chat/royal-dawn-8676/" - -
127.0.0.1:56677 - - [20/Feb/2018:17:18:41] "WSCONNECTING /chat/royal-dawn-8676/" - -
127.0.0.1:56677 - - [20/Feb/2018:17:18:43] "WSDISCONNECT /chat/royal-dawn-8676/" - -
127.0.0.1:56680 - - [20/Feb/2018:17:18:45] "WSCONNECTING /chat/royal-dawn-8676/" - -
127.0.0.1:56680 - - [20/Feb/2018:17:18:47] "WSDISCONNECT /chat/royal-dawn-8676/" - -

Note: My Django Version -1.11.8, Channels Version-1.1.6

Upvotes: 1

Views: 1527

Answers (1)

Darwin
Darwin

Reputation: 338

I had the same problem. add this line of code. on chat/consumers.py on the ws_connect function

def ws_connect(message): message.reply_channel.send({"accept": True}) ...

Upvotes: 3

Related Questions