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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent

解决方案

  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`).

无效尝试

常见但无效的做法:

  1. 70% 失败

    The issue may be transient network flapping, not server failure.

  2. 100% 失败

    The connection is already closed; data will be lost.