{
  "id": "python/starlette-invalid-websocket-close-code",
  "signature": "RuntimeError: Invalid close code: 1006",
  "signature_zh": "运行时错误：无效的关闭代码：1006",
  "regex": "RuntimeError:\\ Invalid\\ close\\ code:\\ 1006",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "WebSocket关闭代码1006是协议保留值，不允许应用层使用",
  "root_cause_type": "generic",
  "root_cause_zh": "WebSocket关闭代码1006是协议保留值，不允许应用层使用",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "尝试使用其他保留代码如1015",
      "why_fails": "所有1000-1015范围的代码都是协议保留",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "忽略错误继续发送消息",
      "why_fails": "连接已关闭，无法继续通信",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "使用合法的关闭代码（如1000正常关闭）",
      "success_rate": 0.95,
      "how": "await websocket.close(code=1000)",
      "condition": "",
      "sources": []
    },
    {
      "action": "使用自定义代码4000-4999范围",
      "success_rate": 0.9,
      "how": "await websocket.close(code=4000)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}