You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker部署Rocket.Chat移动端提示Websocket禁用问题求助

解决Rocket.Chat移动端Websocket禁用提示的方案

1. 确认Rocket.Chat容器的环境变量配置

Docker部署时,必须确保以下关键环境变量正确设置,否则移动端会检测不到Websocket:

-e ROOT_URL=https://chat.my-domain.de  # 必须是对外可访问的HTTPS地址
-e WEBSOCKET_ENABLED=true             # 显式启用Websocket
-e FORWARDED_IP_TRUST_PROXY=true      # 信任Nginx的反向代理IP

如果使用docker-compose,在environment块中添加上述变量。

2. 修复Nginx配置的Websocket支持

你的现有配置缺少$connection_upgrade变量的定义,且未设置长连接超时,补充以下内容:

步骤1:添加变量映射(在http块或当前server块上方)

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

步骤2:完善location块的超时设置

修改你的location配置,增加超时参数:

location ~ ^/.* {
    proxy_pass https://chat.my-domain.de:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Nginx-Proxy true;
    proxy_redirect off;
    # 增加Websocket长连接超时
    proxy_connect_timeout 7d;
    proxy_send_timeout 7d;
    proxy_read_timeout 7d;
}

注意:Plesk环境的配置方式

不要直接修改Nginx配置文件,登录Plesk后台,找到对应域名的Apache & Nginx Settings,在Additional Nginx directives中添加上述配置,避免被Plesk自动覆盖。

3. 排查网络与CDN限制

  • 检查服务器防火墙:确保仅允许Nginx访问3000端口,对外开放443端口(HTTPS)。
  • 若使用Cloudflare等CDN:在CDN控制台开启WebSockets支持,并确保SSL模式设置为Full或Full (strict)。

4. 测试Websocket连接有效性

安装wscat工具测试连接:

npm install -g wscat
wscat -c wss://chat.my-domain.de/websocket
  • 若成功连接并收到JSON消息,说明Websocket正常,建议用户清空移动端应用缓存或重新安装。
  • 若连接失败,根据错误信息(如超时、拒绝)进一步排查端口、防火墙或Nginx配置。

5. 查看Rocket.Chat容器日志

通过日志定位问题:

docker logs <你的Rocket.Chat容器名称或ID>

查找包含websocket的日志条目,确认是否有环境变量错误、连接被拒绝等异常信息。

内容的提问来源于stack exchange,提问作者fehmelchen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 22:28:13