Reputation: 319
I'm trying to configure django channels to run on my ubuntu server(digital ocean).
I have redis-server running on port 6379
.
Daphne is listening on endpoint unix:/home/mysite/sockets/mysite.sock
with HTTP/2 support enabled
(not sure that's required at this stage)
I also have one ./manage.py runworker
Listening.
My daphne run command was
daphne -u /home/mysite/sockets/mysite.sock project.asgi:channel_layer
My http requests come through(in the daphne log) as they did in my local environment e.g.
#local
127.0.0.1:62241 - - [09/Oct/2017:21:03:41] "GET /playground/channel-simple" 200 1826
#server (side note. not sure why port + host are eliminated here.?)
None - - [09/Oct/2017:21:53:51] "GET /playground/channel-simple" 200 1622
However, when I request a websocket url via js everything falls to pieces...
#local
127.0.0.1:62268 - - [09/Oct/2017:21:03:43] "WSCONNECTING /chat/private-room/" - -
127.0.0.1:62268 - - [09/Oct/2017:21:03:43] "WSCONNECT /chat/private-room/" - -
#server
None - - [09/Oct/2017:21:54:04] "GET /chat/private-room/" 404 86
It looks like it's treating the request as an http request rather than a websocket connection? This is also the js console log...
#server - js response to connection
WebSocket connection to 'ws://[MY-IP]/chat/private-room/' failed: Error during WebSocket handshake: Unexpected response code: 404
Can anyone advise as to where this 404 might be getting fired? Or any tips on debugging.
Thanks.
Upvotes: 5
Views: 2968
Reputation: 319
I've figured out the issue here and have now got it working on the server as expected. I had not completed the nginx config. Noob :).
The following articles were of great use.
https://www.nginx.com/blog/websocket-nginx/
http://masnun.rocks/2016/11/02/deploying-django-channels-using-daphne/
Upvotes: 4