If I keep browser tab active (open it at least once per 5-6 mins) my WebSocket connection keeps alive through ping requests (see attached screenshot). But if I abandon the tab for 10 minutes or so, /ping requests stop happening and WebSocket connection terminates. Any explanation for this and how can it be bypassed to keep connection alive while device is awake?
PS: I suspect that our recent migration to Azure Web services could be related. Or some browser policies could change. Having SignalR implemented for a few years we now experience such issues for the first time.
If a server does not become available within the disconnect timeout period, the SignalR connection ends. In this scenario, the Closed event ( disconnected in JavaScript clients) is raised on the client but OnDisconnected is never called on the server.
Configuration. ConnectionTimeout = TimeSpan. FromSeconds(40); // Wait a maximum of 30 seconds after a transport connection is lost // before raising the Disconnected event to terminate the SignalR connection.
hub. stop(). done(function() { alert('stopped'); });
In the default mode, the app server creates five server connections with Azure SignalR Service. The app server uses the Azure SignalR Service SDK by default. In the following performance test results, server connections are increased to 15 (or more for broadcasting and sending a message to a big group).
We were able to mitigate the issue by increasing disconnect timeout to 90s and setting keep alive property to 10s on the server (ASP.NET app).
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(90);
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);
But I'm still waiting for an official response on Github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With