{
  "id": "dotnet/signalr-negotiate-timeout",
  "signature": "Microsoft.AspNetCore.SignalR.HubException: Failed to negotiate with the server. The negotiation request timed out after 30 seconds.",
  "signature_zh": "Microsoft.AspNetCore.SignalR.HubException: 与服务器协商失败。协商请求在 30 秒后超时。",
  "regex": "HubException: Failed to negotiate with the server.*timed out after \\d+ seconds",
  "domain": "dotnet",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "SignalR client fails to complete the negotiation handshake within the default timeout, typically due to network latency, server overload, or firewall blocking the WebSocket upgrade.",
  "root_cause_type": "generic",
  "root_cause_zh": "SignalR 客户端未能在默认超时时间内完成协商握手，通常是由于网络延迟、服务器过载或防火墙阻止 WebSocket 升级。",
  "versions": [
    {
      "version": "6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Increasing the client timeout alone may mask underlying network issues; the server must also handle long-running negotiations.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling WebSocket transport forces fallback to long polling, which can degrade performance and still timeout if the server is overloaded.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the negotiation timeout on the client: in JavaScript, use 'const connection = new signalR.HubConnectionBuilder().withUrl('/hub').configureLogging(signalR.LogLevel.Information).build();' and set 'connection.serverTimeoutInMilliseconds = 60000;' before starting.",
      "success_rate": 0.8,
      "how": "Increase the negotiation timeout on the client: in JavaScript, use 'const connection = new signalR.HubConnectionBuilder().withUrl('/hub').configureLogging(signalR.LogLevel.Information).build();' and set 'connection.serverTimeoutInMilliseconds = 60000;' before starting.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Optimize server-side negotiation by reducing the number of transports offered: in Program.cs, use 'app.MapHub<MyHub>(\"/hub\", options => { options.Transports = HttpTransportType.WebSockets | HttpTransportType.ServerSentEvents; });' to skip slow transport negotiation.",
      "success_rate": 0.75,
      "how": "Optimize server-side negotiation by reducing the number of transports offered: in Program.cs, use 'app.MapHub<MyHub>(\"/hub\", options => { options.Transports = HttpTransportType.WebSockets | HttpTransportType.ServerSentEvents; });' to skip slow transport negotiation.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase the negotiation timeout on the client: in JavaScript, use 'const connection = new signalR.HubConnectionBuilder().withUrl('/hub').configureLogging(signalR.LogLevel.Information).build();' and set 'connection.serverTimeoutInMilliseconds = 60000;' before starting.",
    "Optimize server-side negotiation by reducing the number of transports offered: in Program.cs, use 'app.MapHub<MyHub>(\"/hub\", options => { options.Transports = HttpTransportType.WebSockets | HttpTransportType.ServerSentEvents; });' to skip slow transport negotiation."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-8.0",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2023-11-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}