django - 在 apache 和 daphne 上托管 django 频道
问题描述
我正在尝试以相同的方式在 apache 上部署 django 聊天应用程序。有人可以帮我设置 daphne 服务器吗?我对部署 django 频道完全陌生。我有一个 linux 虚拟机(ubuntu)。该站点正在运行,但未建立 websocket 连接。我在控制台中看到的错误是:
(index):16 WebSocket connection to 'ws://chat.bagdigital.in/ws/chat/lobby/' failed:
(anonymous) @ (index):16
(index):30 Chat socket closed unexpectedly
chatSocket.onclose @ (index):30
这是我的 apache conf 文件。
<VirtualHost *:80>
ServerName chat.bagdigital.in
#ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error_chat_bagwebsite.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/pksingh/chat-app/chat-api/static
Alias /media /home/pksingh/chat-app/chat-api/media
<Directory /home/pksingh/chat-app/chat-api/static>
Require all granted
</Directory>
<Directory /home/pksingh/chat-app/chat-api/media>
Require all granted
</Directory>
<Directory /home/pksingh/chat-app/chat-api/chatapi>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/pksingh/chat-app/chat-api/chatapi/wsgi.py
WSGIDaemonProcess bag_chat_app python-path=/home/pksingh/chat-app/chat-api python-home=/home/pksingh/chat-app/chat-api/venv
WSGIProcessGroup bag_chat_app
我已经安装了redis服务器。如果我在端口 8000 上正常运行 django 服务器而不使用 apache,则套接字连接运行良好。
python3 manage.py runserver 0.0.0.0:8000 &
有人可以帮我在这里设置 daphne 服务器吗?
解决方案
推荐阅读
- python-3.x - Cat 代码在 Matplotlib 中无法正常工作
- c++ - 如何防止 GCC 重新排序对特殊内存区域的写入?
- python - 我正在尝试检测一种语言,然后将其翻译成英语,但有些不对劲
- forms - 是否可以在 Microsoft Forms 上为每个 Teams 课程提交表格并自动填写教授姓名?
- node.js - 如何将键值对转换为相同键值对的数组
- xamarin - Adding Reverb effect to MediaPlayer in 'Mobile App (Xamarin.Forms)' project
- javascript - 每当我打开某人的图像时反应状态更新错误,并且图像也没有重新渲染。我该如何解决这个错误
- bash - grep 模式并找到该行的最后一个单词
- node.js - 为什么导入 bcrypt 会导致“找不到模块 napi-v3/bcrypt_lib.node”错误?
- google-tag-manager - Fb Pixel Tags 在预览模式下触发,但不在实时模式下