New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SignalR Client Disconnected Event not called when internet connection is lost #3919
Comments
FYI I am connecting from a different computer than the server, unlike the last person who had this same problem. |
There is no reliable method of detecting that the cable has been unplugged and pending HTTP requests might not be terminated if this happens. Longpolling transport is the only transport that does not have keep alive (we tried adding it and it caused more problems than it solved). There is a poll timeout of 120 seconds after which client should try re-poll which should fail because new HTTP requests - as you noticed - cannot be make. This should lead to reconnects. Also, reconnects are not indefinite - if the client cannot reconnect within a timeout the connection will be closed. |
@moozzyk Thanks for your quick response! I appreciate it. Here is the code that I am using to generate the log
|
foreverFrame needs to be investigated then. The client should give up reconnecting if it could not re-establish connection within reconnect timeout/window. |
The problem is its not just foreverFrame, its sse and long polling as well, here are some more logs for each of those. |
I'm new to Gethub so sorry if this is the wrong place, but what happens to this form here? Any suggestions on how to report the status of the connection to the UI? |
A co-worker finally pointed me to the problem I was overriding the handlers instead of passing my function to them $.connection.hub.disconnected = function(){console.log("[" + (new Date()).toString() + "] SignalR Connection Disconnected"); }; vs |
This issue has been closed as part of issue clean-up as described in https://blogs.msdn.microsoft.com/webdev/2018/09/17/the-future-of-asp-net-signalr/. If you're still encountering this problem, please feel free to re-open and comment to let us know! We're still interested in hearing from you, the backlog just got a little big and we had to do a bulk clean up to get back on top of things. Thanks for your continued feedback! |
Expected behavior
The $.connection.hub.disconnected should get called after 30 seconds of the client not being able to talk to the server
Actual behavior
It keeps trying to reconnect indefinitely
Steps to reproduce
Handel all the events
$.connection.hub.connectionSlow = function(){console.log("[" + (new Date()).toString() + "] SignalR Connection Slow");};
$.connection.hub.reconnecting = function(){console.log("[" + (new Date()).toString() + "] SignalR Connection Reconnecting"); };
$.connection.hub.reconnected = function(){console.log("[" + (new Date()).toString() + "] SignalR Connection Reconnected");};
$.connection.hub.disconnected = function(){console.log("[" + (new Date()).toString() + "] SignalR Connection Disconnected"); };
$.connection.hub.stateChanged = function () { console.log("[" + (new Date()).toString() + "] SignalR StateChange");
$.connection.hub.logging = true;
Connect with Start
Turn off wifi or pull the plug on the internet
This is the only thing that shows in the logs, the disconnected event is never fired.
In Chrome
XHR failed loading: POST "http://xxxxxxxx/signalr/poll?transport=longPolling& net::ERR_INTERNET_DISCONNECTED
In IE11
[18:02:51 GMT-0700 (US Mountain Standard Time)] SignalR: Opening long polling request to 'http://xxxxxxx/signalr/reconnect?transport=longPolling&clientProtocol=1.5&connectionToken=cvKizCrqc3saz0gQuNvTaMeB91jkPeVOP4cBz3ZDgzdsi7iQm4aC25dBr%2BxjWwEetYS8PEh0jlVuu9Q0UL9RUzBD4klYw3EBhYgP10p0wcBccPYY0BW%2BSH4EyPxff2AaSBsAfrqsJBiUTrbA5DV7Jw%3D%3D&connectionData=%5B%7B%22name%22%3A%22realtimeinboxhub%22%7D%5D'.
SCRIPT7002: XMLHttpRequest: Network Error 0x2ee7, Could not complete the operation due to error 00002ee7.
Note we are not using web sockets
With Forever frames we see this, but still no disconnected event is raised on the client
[18:30:15 GMT-0700 (US Mountain Standard Time)] SignalR: Keep alive has been missed, connection may be dead/slow.
[18:30:22 GMT-0700 (US Mountain Standard Time)] SignalR: Keep alive timed out. Notifying transport that connection has been lost.
[18:30:24 GMT-0700 (US Mountain Standard Time)] SignalR: Updating iframe src to 'http://xxxxx/signalr/reconnect?transport=foreverFrame&groupsToken=vdn69Z4r7I2HFeyiTwC7V06mYy4t0P67Y5yDr9HGQjhISisu0%2B484DIW9G0eV33yAqp1TQ8vgH4L07UQ3Uor%2BAC2FGNsLrH7OEyigVMVsocgSvSzQUmzpStCDvNG2ir3qiOl4ITLOuIKQREA%2B%2BUNRg%3D%3D&messageId=s-0%2C3979&clientProtocol=1.5&connectionToken=KlY0U0ZuDWgNrsUdhGWsyO2%2FKk1ltTvvDI25ncWYV%2FZN%2BSR9MufllEMiDSZXjNAkHy%2Be21M7dUXx8%2BSOb%2BqoTf2ZUA3c%2FStYpbJSCv6XBkgKgDKrQd9hKZoW1KTTlVEWN7g9VClztVn1N2Y4FBBLFA%3D%3D&connectionData=%5B%7B%22name%22%3A%22realtimeinboxhub%22%7D%5D&tid=2&frameId=1'.
[18:30:24 GMT-0700 (US Mountain Standard Time)] SignalR: Forever frame iframe finished loading and is no longer receiving messages.
The text was updated successfully, but these errors were encountered: