问题描述
我正在记录网络游戏中的断开连接.似乎75%的会话已与代码1001(正常)断开连接,而25%的会话已与代码1006(错误)断开连接. https://tools.ietf.org/html/rfc6455
I'm logging disconnects in my web game. It seems 75% of the sessions are getting disconnected with the code 1001 (normal) and 25% are getting disconnected with the code 1006 (error). https://tools.ietf.org/html/rfc6455
有时由于错误原因,我看到此文本:
Sometimes on the error reason I see this text:
但是他绝大部分1006次断开连接都没有给出任何理由.玩家完全没有任何理由断开连接.这通常发生在玩家积极玩游戏的5-30分钟.
But he majority of 1006 disconnects don't give any reason at all. The players just disconnect with no reason at all. This usually happens at 5-30 minutes mark while the player is actively playing the game.
我具有以下设置:
- Node.js
- Express.js
- Cloudflare
- 数字海洋
- Docker
- https://github.com/websockets/ws
- SSL
- Nginx超时= 3600秒
- Ping/Pong isAlive = 30s
我的问题是:
- 如何更好地调试此问题?
- 哪些常见情况可能导致此问题?
推荐答案
出现此特定错误的原因是因为Cloudflare更新了其SSL,防火墙,Nginx,物理服务器的软件或配置.
The reason for this specific error is because Cloudflare updates software or configuration of their SSL, Firewall, Nginx, physical servers.
他们系统中几乎所有要更新的堆栈都会踢出您的websocket.您有2种解决方案:
Almost any stack in their system being updated will kick out your websockets. You have 2 solutions:
- Websockets不使用Cloudflare
- 具有自动重新连接逻辑
这篇关于Websocket断开连接并出现1006错误,没有任何原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!