However none of these events are being fired. I took it a step further and put logging on all the events I could yet none of them are being called the connection drops.
However none of these events are being fired. I took it a step further and put logging on all the events I could yet none of them are being called the connection drops.
Try to use the following code, I test it on my side, it seems that the disconnected event works well on my side:
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Thank you for your quick response, I already tried that method and I even tried that exact code and its not triggering when I stop the app pool for example. Could something be conflicting with just these events? When its connected everything works great.
None
0 Points
11 Posts
How to notify the user about disconnections?
Jun 15, 2017 09:44 PM|jakeb16|LINK
I need some help figuring out how to let our users know the connection is disconnected. I'm using the latest version 2.2.2
I read this https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/handling-connection-lifetime-events#notifydisconnect
However none of these events are being fired. I took it a step further and put logging on all the events I could yet none of them are being called the connection drops.
$.connection.hub.connectionSlow = RealTimeInboxConnectionSlow;
$.connection.hub.reconnecting = RealTimeInboxReconnecting;
$.connection.hub.reconnected = RealTimeInboxReconnected;
$.connection.hub.disconnected = RealTimeInboxDisconnected;
$.connection.hub.stateChanged = function () { RealTimeInboxSignalRConsoleLog("StateChange"); };
$.connection.hub.error(function (error) { RealTimeInboxSignalRConsoleLog('Error: ' + error) });
$.connection.hub.received(function (data) { RealTimeInboxSignalRConsoleLog('Received: ' +JSON.stringify(data)) });
$.connection.hub.logging = true;
This is What I see in the browser console when the app pool is stopped is a loop of trying to reconnect
14:36:16 GMT-0700 (US Mountain Standard Time)] SignalR: EventSource readyState: 0.
[14:36:16 GMT-0700 (US Mountain Standard Time)] SignalR: EventSource reconnecting due to the server connection ending.
[14:36:18 GMT-0700 (US Mountain Standard Time)] SignalR: EventSource calling close().
[14:36:18 GMT-0700 (US Mountain Standard Time)] SignalR: serverSentEvents reconnecting.
14:36:18 GMT-0700 (US Mountain Standard Time)] SignalR: Attempting to connect to SSE endpoint
[14:36:18 GMT-0700 (US Mountain Standard Time)] SignalR: EventSource readyState: 2.
[14:36:18 GMT-0700 (US Mountain Standard Time)] SignalR: EventSource reconnecting due to the server connection ending.
[14:36:20 GMT-0700 (US Mountain Standard Time)] SignalR: EventSource calling close().
Over and Over again.
I reported this as a issue on github but I dont see how I can be the only one facing this problem.
Any one have any suggustions?
I am using SSE, forever frames, and long polling (we dont have the newer version of Windows so we cant use winsockets)
All-Star
45489 Points
7008 Posts
Microsoft
Re: How to notify the user about disconnections?
Jun 16, 2017 05:12 AM|Zhi Lv - MSFT|LINK
Hi jakeb16,
Try to use the following code, I test it on my side, it seems that the disconnected event works well on my side:
Best regards,
Dillion
None
0 Points
11 Posts
Re: How to notify the user about disconnections?
Jun 16, 2017 04:40 PM|jakeb16|LINK
Thank you for your quick response, I already tried that method and I even tried that exact code and its not triggering when I stop the app pool for example. Could something be conflicting with just these events? When its connected everything works great.
None
0 Points
11 Posts
Re: How to notify the user about disconnections?
Jun 16, 2017 07:24 PM|jakeb16|LINK
A co-worker finally pointed me to the problem I was overriding the handlers instead of passing my function to them
$.connection.hub.disconnected = RealTimeInboxDisconnected;
vs
$.connection.hub.disconnected( RealTimeInboxDisconnected);