Skip to content
Advertisement

Trouble getting started with Django Channels

I am creating my own application inspired from the Channels 2.0 tutorial. However, I am unable to establish WebSocket connection. Daphne complains for 404 saying the websocket URL can not be found. I am not sure where the error is.

UPDATE: My Daphne is running behind an nginx server. The nginx config is updated as well:

My directory structure is as follows

JavaScript

WebSocketTest/templates/WebSocketTest/Index.html

JavaScript

WebSocketTest/views.py

JavaScript

WebSocketTest/consumers.py

JavaScript

WebSocketTest/routing.py

JavaScript

WebSocketTest/urls.py

JavaScript

Dashboard/routing.py

JavaScript

Dashboard/urls.py

JavaScript

Daphne Error log

JavaScript

Nginx.conf

JavaScript

Advertisement

Answer

After a little bit of search, I found it’s an issue with Nginx config. The nginx config I posted does not allow websockets. The following change needs to be done:

JavaScript

More details available at the Nginx blog post

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement