CoinFlip
CoinFlip

Reputation: 23

SignalR hub OnDisconnected firing time in different browsers after page reload

I encountered the situation when my hub's OnDisconnected event happens after the asp.net mvc action on page refresh for the Chrome browser, however for FireFox and IE the behavior is different, the event is fired before the related asp.net mvc action. Is there any fixed rule for this?

The order is important for me, at least i expect it to be the same for all browsers, is there any way to ensure the same order?

Upvotes: 2

Views: 1094

Answers (1)

N. Taylor Mullen
N. Taylor Mullen

Reputation: 18301

MVC action or not you cannot ensure order.

Here's why: When a user attempts to navigate away from a page with an active SignalR connection, SignalR will then make a "best effort" attempt to notify the server that the client connection will be stopped. If our "best effort" attempt fails to reach the server the server will "forget" about the user after a configurable "DisconnectTimeout" later at which time the OnDisconnected event will fire. If our "best effort" attempt is successful the OnDisconnected event will fire immediately.

Seeing that this behavior is run as a user is leaving a page and is dependent on the client, it can be inconsistent.

Hope this helps!

Upvotes: 3

Related Questions