SignalR does not fire a "disabled" event

I am using SignalR to send updates to connected web clients. I am listening to an event disconnected

to know when I should start the reconnect logic

$.connection.hub.disconnected(function() {
    // Initiate my own reconnection logic
});

      

SignalR Console is hosted on IIS (along with my site)

[assembly: OwinStartup(typeof(Startup))]
namespace MyNamespace.SignalR
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}

      

After connecting, the client calls the server method to join the group

public class MyHub : Hub
{
    public void JoinGroup(string groupName)
    {
        Groups.Add(Context.ConnectionId, groupName);
    }
}

      

And then I output messages to this group:

context.Clients.Group(groupName).sendMessage();

      

If I manually recycle the application pool in IIS, SignalR starts trying to connect and I end up getting a disconnected

client side event if it doesn't work (after timeout).

However, my problem is that if I manually reload the website in IIS, I don't get any event at all disconnected

, and I don't see in the logs that SignalR detected any connection problem at all. How can I detect that I have been disconnected?

I know that I should probably persist in group communication, as it is memorized, I think. But that shouldn't affect the original issue where the client doesn't receive disconnect notification? Should the client code signalr throw some kind of exception / event?

+3


source to share


2 answers


So, I finally figured out what the problem is and how to solve it. Some suggestions:

We are currently manually publishing new versions of our application by going to "General Settings ..." under the website in IIS and changing the "Physical Path" from C:\websites\version1

to C:\websites\version2

. Apparently this gives the same behavior as restarting the website in IIS (not a hard reset, not stopping the website, not reusing the application pool) and according to this : "DOES NOT close the site, it just deletes the Http.sys binding for this port. " And no matter how long we wait, connected clients will never receive any indication to reconnect.



So the solution is to restart the application pool after each version. "Lost" clients will receive disabled events and reconnect to the new version of the site.

0


source


disconnected

fires first when inline reconnect logic is disabled. You also need to listen for the recconect event, something like this I am here



https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/blob/ReconnectOnClosed/SignalR.EventAggregatorProxy.Client.JS/jquery.signalR.eventAggregator.js#L157

+3


source







All Articles