Md. Najrul Islam
Md. Najrul Islam

Reputation: 77

Azure SignalR withAutomaticReconnect() "Error: Connection disconnected with error"... on Angular8 & Asp.Net Core 3.1

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.

enter image description here

Upvotes: 1

Views: 3976

Answers (1)

Fei Han
Fei Han

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 KeepAliveIntervaloption 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

enter image description here

Upvotes: 3

Related Questions