我正在尝试配置 django 频道以在我的 ubuntu 服务器(数字海洋)上运行。
我有 redis-server 运行在port 6379
. 达芙妮在端点上监听unix:/home/mysite/sockets/mysite.sock
(HTTP/2 support enabled
不确定现阶段是否需要)我也有一个./manage.py runworker
监听。我的 daphne 运行命令是
daphne -u /home/mysite/sockets/mysite.sock project.asgi:channel_layer
我的 http 请求通过(在 daphne 日志中)就像在我的本地环境中一样,例如
#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
但是,当我通过 js 请求 websocket url 时,一切都崩溃了......
#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
看起来它将请求视为http请求而不是websocket连接?这也是js控制台日志...
#server - js response to connection
WebSocket connection to 'ws://[MY-IP]/chat/private-room/' failed: Error during WebSocket handshake: Unexpected response code: 404
谁能建议这个 404 可能在哪里被解雇?或有关调试的任何提示。
谢谢。