1005
api
network_error
ai_generated
partial
WebSocket 关闭代码 1005:异常关闭(未收到状态码)
WebSocket close code 1005: Abnormal Closure (no status code received)
ID: api/websocket-close-code-1005-abnormal-close-no-status
80%修复率
85%置信度
1证据数
2024-05-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| RFC 6455 | active | — | — | — |
| WebSocket API (W3C) | active | — | — | — |
| Node.js ws v8 | active | — | — | — |
| Python websockets v12 | active | — | — | — |
根因分析
WebSocket 连接在未发送关闭帧的情况下终止,通常由网络中断、服务器崩溃或代理超时引起。
English
The WebSocket connection was terminated without sending a close frame, often due to network interruption, server crash, or proxy timeout.
官方文档
https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent解决方案
-
Implement automatic reconnection with exponential backoff in the client: `function reconnect() { setTimeout(() => new WebSocket(url), 1000 * Math.pow(2, attempts)); }` -
Check server and proxy logs for timeout or resource exhaustion; increase WebSocket timeout settings (e.g., `nginx proxy_read_timeout 3600s`).
无效尝试
常见但无效的做法:
-
70% 失败
The issue may be transient network flapping, not server failure.
-
100% 失败
The connection is already closed; data will be lost.