我目前正在尝试设置我的 Django Channels 聊天应用程序,并且我已经尽我所能地遵循了文档 - 显然,当出现问题时,总有解决方案,但我只是很难找出我的位置让这个工作出错了。
\n到目前为止,我已经安装了 Django Channels,在 settings.py 中正确配置了我的channel_layer,我已经参考了文档和其他在线教程来创建我的consumer.py 文件、utils.py、views.py 和chat.html 模板文件。
\n我还配置了 nginx、gunicorn、daphne 和 redis,我可以确认所有这些服务都在运行。我已经安装了 LetsEncrypt 并允许使用 SSL 端口(https 连接为 443)。
\n我目前正在实时生产服务器上访问我的 Django 网站,如下所示:https://mydomain:8001,并且我的聊天的直接链接配置为 https://mydomain:8001/messenger
\n(我已允许端口 8001 通过我的防火墙)
\n以下是我从聊天页面收到的状态消息:
\nSUCCESS {response: "Successfully got the chat.", chatroom_id: 1}chatroom_id: 1response: "Successfully got the chat."__proto__: Object\n(index):303 setupWebSocket: 1\n(index):371 ChatSocket connecting..\nWebSocket connection to 'wss://www.<mydomain>.com:8001/messenger/1/' failed: \nsetupWebSocket @ (index):317\nsuccess @ (index):389\nc @ jquery.min.js\nfireWith @ jquery.min.js\nl @ jquery.min.js\n(anonymous) @ jquery.min.js\nChatSocket error Event\xc2\xa0{isTrusted: true, type: "error", target: WebSocket, …
Run Code Online (Sandbox Code Playgroud)