SignalR long disconnection timeout on Azure

Viewed 405

I have an ASP .Net Core server app with SignalR. There is also a client app also written with .Net Core and SignalR. The client connects to the server and they work together.

While working in a local development environment everything works as expected but when I deploy my Server app to the Azure App Service I noticed weird behaviour.

When the client disconnects from the server, the event that the client disconnected comes with a huge lag of ~30 seconds. While other calls between the client and the server work normally, we observe the lag only with client disconnection event.

While investigating this issue I came up with solution to reduce the KeepAliveInterval in server settings;

.AddSignalR(configure =>
{
    configure.EnableDetailedErrors = true;
    configure.MaximumReceiveMessageSize = null;
    configure.KeepAliveInterval = TimeSpan.FromSeconds(1);
    configure.EnableDetailedErrors = true;
});

And then the client disconnection event is immediate.

Can someone explain why this issue occurs on Release version on Azure?

The issue did not happen in the local Development environment.

The issue did not happen in the local Release environment.

1 Answers

In a SignalR Hub OnReconnected Event Handler can execute directly after the OnConnected but not after the OnDisconnected for a given client. The reasons of reconnection without a disconnection is for several ways here

enter image description here

Physical connections might be slow or there might be interruptions in connectivity. Depending on factors such as the length of the interruption, the transport connection might be dropped. SignalR then tries to re-establish the transport connection. Sometimes the transport connection API detects the interruption and drops the transport connection, and SignalR finds out immediately that the connection is lost.

In other scenarios, neither the transport connection API nor SignalR becomes aware immediately that connectivity has been lost. For all transports except long polling, the SignalR client uses a function called keepalive to check for loss of connectivity that the transport API is unable to detect. For information about long polling connections, see here Timeout and keepalive settings l

Refer for more info

Related