Reputation: 77
I am using Azure SignalR on Asp.Net Core 3.1 and Angular8. I also user withAutomaticReconnect() option on client side. It connect with azure signalr successfully. But after some times it show this error message and connected to the WebSocket again.
Upvotes: 1
Views: 3976
Reputation: 27793
Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'
The default serverTimeoutInMilliseconds
value is 30,000 milliseconds (30 seconds), if this timeout elapses without receiving any messages from the server, the connection will be terminated with above error.
Please check if you configured/changed KeepAliveInterval
option of your SignalR hub server.
When changing KeepAliveInterval
, we should change the serverTimeoutInMilliseconds
setting on the client side. And the recommended serverTimeoutInMilliseconds
value is double the KeepAliveInterval
value.
For example:
On hub server, change KeepAliveInterval to 1 minute
services.AddSignalR(hubOptions =>
{
hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(1);
}).AddAzureSignalR();
On client side, change serverTimeoutInMilliseconds to 2 minutes
this.hubConnection.serverTimeoutInMilliseconds = 120000;
Test Result
Upvotes: 3