Search code examples
asp.net-web-apisignalrsignalr-hub

Unable to reconnect SignalR JS client after recycle of application pool


When i recycle my Application Pool for the site where the SignalR hub is running, the javascript clients is unable to reconnect. But everything is OK if the client do a refresh on his browser.

In the clients console log, these lines repeat multiple times every second after a reset of the app pool: ( i have replaced the connection token with abcd )

LOGG: [15:51:19 UTC+0200] SignalR: Raising the reconnect event  
LOGG: [15:51:19 UTC+0200] SignalR: An error occurred using longPolling. Status = parsererror. undefined  
LOGG: [15:51:19 UTC+0200] SignalR: SignalR: Initializing long polling connection with server.  
LOGG: [15:51:19 UTC+0200] SignalR: Attempting to connect to 'http://lab/signalr/reconnect?transport=longPolling&connectionToken=abcd' using longPolling. 
LOGG: [15:51:19 UTC+0200] SignalR: Raising the reconnect event 

I have tried disabling all authentication on the hub, but still the same result. Both the server and client is running on SignalR v1.0.1

The hubconnection on the client is set up like this:

var connection = $.hubConnection('http://lab:8097', { logging: true });
var proxy = connection.createHubProxy('task');
connection.start({ jsonp: true }).done(function () {
    proxy.invoke('OpenTask', id);
});

Im also using crossdomain on the server side hub registration:

RouteTable.Routes.MapHubs(new HubConfiguration { EnableCrossDomain = true });

The server is running on IIS 7.5, and the client is IE9.

Anyone have an idea what's wrong?


Solution

  • This issue will be resolved in 1.1 RTW (not released yet, currently only the beta is out).

    For your reference here's the fix: https://github.com/SignalR/SignalR/issues/1809. If you'd like to have the fix earlier you can implement the changes noted in the issue.

    Lastly, if you do choose to implement the fix you will need to handle the .disconnected event on the connection and restart the connection entirely.