{
  "id": "api/websocket-close-code-1001-endpoint-unavailable",
  "signature": "WebSocket close code 1001: Endpoint Unavailable",
  "signature_zh": "WebSocket 关闭代码 1001：端点不可用",
  "regex": "WebSocket close code 1001: Endpoint Unavailable",
  "domain": "api",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The server is shutting down or the WebSocket endpoint is temporarily unavailable, causing an intentional close with code 1001.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务器正在关闭或 WebSocket 端点暂时不可用，导致使用代码 1001 有意关闭连接。",
  "versions": [
    {
      "version": "WebSocket Protocol RFC 6455",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Node.js ws library 8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Python websockets 11.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Spring WebSocket 6.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The server may still be unavailable; immediate reconnection often fails repeatedly and increases server load.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Code 1001 is a server-initiated close due to unavailability, not a protocol version mismatch.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Compression settings are unrelated to server endpoint availability.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement exponential backoff reconnection logic. Example in JavaScript:\nlet delay = 1000;\nfunction reconnect() {\n  setTimeout(() => {\n    const ws = new WebSocket('wss://api.example.com/socket');\n    ws.onclose = (event) => {\n      if (event.code === 1001) {\n        delay = Math.min(delay * 2, 30000);\n        reconnect();\n      }\n    };\n  }, delay);\n}",
      "success_rate": 0.8,
      "how": "Implement exponential backoff reconnection logic. Example in JavaScript:\nlet delay = 1000;\nfunction reconnect() {\n  setTimeout(() => {\n    const ws = new WebSocket('wss://api.example.com/socket');\n    ws.onclose = (event) => {\n      if (event.code === 1001) {\n        delay = Math.min(delay * 2, 30000);\n        reconnect();\n      }\n    };\n  }, delay);\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check server health endpoint before reconnecting to ensure the WebSocket server is back online.",
      "success_rate": 0.85,
      "how": "Check server health endpoint before reconnecting to ensure the WebSocket server is back online.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a load balancer, verify that health checks are configured correctly for the WebSocket service to avoid routing to unhealthy instances.",
      "success_rate": 0.75,
      "how": "If using a load balancer, verify that health checks are configured correctly for the WebSocket service to avoid routing to unhealthy instances.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Implement exponential backoff reconnection logic. Example in JavaScript:\nlet delay = 1000;\nfunction reconnect() {\n  setTimeout(() => {\n    const ws = new WebSocket('wss://api.example.com/socket');\n    ws.onclose = (event) => {\n      if (event.code === 1001) {\n        delay = Math.min(delay * 2, 30000);\n        reconnect();\n      }\n    };\n  }, delay);\n}",
    "Check server health endpoint before reconnecting to ensure the WebSocket server is back online.",
    "If using a load balancer, verify that health checks are configured correctly for the WebSocket service to avoid routing to unhealthy instances."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/statusCode",
  "official_doc_section": null,
  "error_code": "1001",
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}