如何调试生产中的 django 通道(nginx)?

How to debug django channels in production (nginx)?

django channels 在我的本地服务器和我的生产环境中的开发服务器上工作;但是,我无法让它在生产中响应,也无法让它与以下 Daphne 命令一起工作(dojos 是项目名称):

daphne -b 0.0.0.0 -p 8001  dojos.asgi:channel_layer

以下是执行命令后发生的示例:

2019-05-08 08:17:18,463 INFO     Starting server at tcp:port=8001:interface=0.0.0.0, channel layer dojos.asgi:channel_layer.
2019-05-08 08:17:18,464 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2019-05-08 08:17:18,464 INFO     Using busy-loop synchronous mode on channel layer
2019-05-08 08:17:18,464 INFO     Listening on endpoint tcp:port=8001:interface=0.0.0.0
127.0.0.1:57186 - - [08/May/2019:08:17:40] "WSCONNECTING /chat/stream/" - -
127.0.0.1:57186 - - [08/May/2019:08:17:44] "WSDISCONNECT /chat/stream/" - -
127.0.0.1:57190 - - [08/May/2019:08:17:46] "WSCONNECTING /chat/stream/" - -
127.0.0.1:57190 - - [08/May/2019:08:17:50] "WSDISCONNECT /chat/stream/" - -
127.0.0.1:57192 - - [08/May/2019:08:17:52] "WSCONNECTING /chat/stream/" - -

(forever)

同时在客户端我得到以下控制台信息:

websocketbridge.js:121 WebSocket connection to 'wss://www.joinourstory.com/chat/stream/' failed: WebSocket is closed before the connection is established.
Disconnected from chat socket

我感觉问题出在 nginx 配置上,所以这是我的配置文件服务器块:

location /chat/stream/ {
    proxy_pass http://0.0.0.0:8001;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $http_host;
}


location /static/ {
    root /home/adam/LOCdojos;
}

我确保 consumers.py 文件有这一行:

def ws_connect(message):
    message.reply_channel.send(dict(accept=True))

我尝试为每个问题安装带有频道面板的 Django 调试工具栏: Debugging django-channels

但在生产环境中并没有帮助。

我卡住了 - 下一步是什么?

我也被这种问题困住了,但是这个:

proxy_pass http://0.0.0.0:8001;

对我来说真的很奇怪 - 它是那样工作的吗?也许:

proxy_pass http://127.0.0.1:8001;