Por*_*son 5 ubuntu websocket redis-server django-channels daphne
我正在尝试配置Django通道以在我的ubuntu服务器(数字海洋)上运行。
我的Redis服务器正在运行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
Run Code Online (Sandbox Code Playgroud)
我的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
Run Code Online (Sandbox Code Playgroud)
但是,当我通过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
Run Code Online (Sandbox Code Playgroud)
似乎将请求视为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
Run Code Online (Sandbox Code Playgroud)
有人可以建议将此404发射到哪里吗?或有关调试的任何提示。
谢谢。
我已经在这里解决了这个问题,现在它可以按预期在服务器上运行。我还没有完成 nginx 配置。小白 :)。
下面的文章很有用。
https://www.nginx.com/blog/websocket-nginx/
http://masnun.rocks/2016/11/02/deploying-django-channels-using-daphne/
| 归档时间: |
|
| 查看次数: |
1268 次 |
| 最近记录: |