1006 api network_error ai_generated partial

WebSocket close code 1006: Abnormal Closure

ID: api/websocket-close-code-1006-abnormal-closure

Also available as: JSON · Markdown · 中文
70%Fix Rate
85%Confidence
1Evidence
2023-11-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
WebSocket RFC 6455 active
ws library v8.16 active
Node.js v20 active

Root Cause

The WebSocket connection was closed unexpectedly without a normal close frame, often due to network issues, proxy timeouts, or server crash.

generic

中文

WebSocket 连接在未发送正常关闭帧的情况下意外关闭,通常由于网络问题、代理超时或服务器崩溃。

Official Documentation

https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1

Workarounds

  1. 85% success Implement exponential backoff reconnection with jitter.
    Implement exponential backoff reconnection with jitter.
  2. 80% success Add a health check endpoint and only reconnect if server is alive.
    Add a health check endpoint and only reconnect if server is alive.

中文步骤

  1. Implement exponential backoff reconnection with jitter.
  2. Add a health check endpoint and only reconnect if server is alive.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Reconnecting without delay may hit the same network issue or server load, causing repeated 1006 closures.

  2. 80% fail

    The error is often network-related, not a code logic bug; rewriting may not address the root cause.

  3. 50% fail

    The library is rarely the cause; the underlying TCP connection is the issue.