# WebSocket 关闭代码 1005：异常关闭（未收到状态码）

- **ID:** `api/websocket-close-code-1005-abnormal-close-no-status`
- **领域:** api
- **类别:** network_error
- **错误码:** `1005`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

WebSocket 连接在未发送关闭帧的情况下终止，通常由网络中断、服务器崩溃或代理超时引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| RFC 6455 | active | — | — |
| WebSocket API (W3C) | active | — | — |
| Node.js ws v8 | active | — | — |
| Python websockets v12 | active | — | — |

## 解决方案

1. ```
   Implement automatic reconnection with exponential backoff in the client: `function reconnect() { setTimeout(() => new WebSocket(url), 1000 * Math.pow(2, attempts)); }`
   ```
2. ```
   Check server and proxy logs for timeout or resource exhaustion; increase WebSocket timeout settings (e.g., `nginx proxy_read_timeout 3600s`).
   ```

## 无效尝试

- **** — The issue may be transient network flapping, not server failure. (70% 失败率)
- **** — The connection is already closed; data will be lost. (100% 失败率)
