SignalR disconnect not being called on internet disconnection/re-connection

asp.net, c#, signalr, signalr-hub, signalr.client

Solution

It will raise disconnected but not immediately. There's configurable a threshold (30 seconds by default) that SignalR will wait (after the underlying tcp connection has gone away and this isn't immediate either) before it considers a client disconnected. If the connection drops and reconnects before the configured timeout then it won't raise OnDisconnected.

If you're never seeing it being raised in some scenario after waiting for a while then it might be a bug. SignalR 1.0 was released today so I'd encourage you to try that as well and see if you still see the problem.

Problem

I am using SignalR in my app.I have an app which depends to a very great degree on `OnDisconnected()` being called correctly. And it is called correctly under the following circumstances: ``` public Task OnDisconnected() { try { DeleteUser(Context.ConnectionId); return null; } catch (Exception ex) { return null; } } ``` - The user refreshes the page - The user navigates to a new page - The user closes the browser However, it is not called if the network connection suddenly drops. For instance, if I unplug the network cable on the client machine, or disable the client's wireless network, or unplug the router, `OnDisconnected()` will never get called, even after a several minute wait.

Original source