{
  "id": "api/websocket-connection-closed-with-code-1000",
  "signature": "WebSocket close code 1000: Normal Closure",
  "signature_zh": "WebSocket 关闭代码 1000：正常关闭",
  "regex": "WebSocket close code 1000: Normal Closure",
  "domain": "api",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "The WebSocket connection was closed normally by either the client or server, often due to a timeout, idle timeout, or explicit close.",
  "root_cause_type": "generic",
  "root_cause_zh": "WebSocket 连接被客户端或服务器正常关闭，通常是由于超时、空闲超时或显式关闭。",
  "versions": [
    {
      "version": "WebSocket RFC 6455",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Node.js ws library v8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Python websockets v10.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Reconnecting immediately without investigating the reason for closure may lead to repeated disconnections if the server enforces a rate limit or idle timeout.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling WebSocket compression or other features incorrectly may not prevent normal closure due to server-side policies.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement automatic reconnection with exponential backoff. Example (JavaScript): function connect() { const ws = new WebSocket('wss://example.com/socket'); ws.onclose = (event) => { if (event.code === 1000) { setTimeout(connect, 1000); } }; }",
      "success_rate": 0.75,
      "how": "Implement automatic reconnection with exponential backoff. Example (JavaScript): function connect() { const ws = new WebSocket('wss://example.com/socket'); ws.onclose = (event) => { if (event.code === 1000) { setTimeout(connect, 1000); } }; }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Send periodic WebSocket ping/pong frames to keep the connection alive and avoid idle timeout. Example (Node.js): ws.ping(); setInterval(() => ws.ping(), 30000);",
      "success_rate": 0.8,
      "how": "Send periodic WebSocket ping/pong frames to keep the connection alive and avoid idle timeout. Example (Node.js): ws.ping(); setInterval(() => ws.ping(), 30000);",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "实现带指数退避的自动重连。示例 (JavaScript)：function connect() { const ws = new WebSocket('wss://example.com/socket'); ws.onclose = (event) => { if (event.code === 1000) { setTimeout(connect, 1000); } }; }",
    "发送定期的 WebSocket ping/pong 帧以保持连接活跃，避免空闲超时。示例 (Node.js)：ws.ping(); setInterval(() => ws.ping(), 30000);"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent",
  "official_doc_section": null,
  "error_code": "1000",
  "verification_tier": "ai_generated",
  "confidence": 0.8,
  "fix_success_rate": 0.75,
  "resolvable": "true",
  "first_seen": "2023-11-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}