dotnet
network_error
ai_generated
partial
Microsoft.AspNetCore.SignalR.HubException: Failed to negotiate with the server. The negotiation request timed out after 30 seconds.
ID: dotnet/signalr-negotiate-timeout
75%Fix Rate
82%Confidence
1Evidence
2023-11-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 6.0 | active | — | — | — |
| 7.0 | active | — | — | — |
| 8.0 | active | — | — | — |
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.
generic中文
SignalR 客户端未能在默认超时时间内完成协商握手,通常是由于网络延迟、服务器过载或防火墙阻止 WebSocket 升级。
Official Documentation
https://learn.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-8.0Workarounds
-
80% success 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.
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. -
75% success 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.
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.
中文步骤
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.
Dead Ends
Common approaches that don't work:
-
60% fail
Increasing the client timeout alone may mask underlying network issues; the server must also handle long-running negotiations.
-
50% fail
Disabling WebSocket transport forces fallback to long polling, which can degrade performance and still timeout if the server is overloaded.