KingOfHypocrites
KingOfHypocrites

Reputation: 9537

SignalR OnDisconnected Not Fired on Internet Connection Loss

It is my understanding that an internet connection loss should fire SignalR disconnect. I am using a code snippet to handle the disconnect but it never gets fired on a loss of internet connection. This causes everything using SignalR to suddenly stop working. Am I missing something here? I am waiting several minutes and the disconnect is set to 30 seconds. Do I need to test for an internet connection loss separately? I read in another post that this shouldn't happen although it was quite old.

; var HubStartup = HubStartup || (function () {
    function start() {
        logDebugInfo('Starting hub router.');
        $.connection.hub.start().done(function () {
            logDebugInfo('Connected to hub router.');
            // Do stuff

        }).fail(function () {
            logDebugError('Unable to start hub router.');
        });
    }

    $.connection.hub.disconnected(function () {
        logDebugInfo('Attempting to reconnect to hub router.');
        setTimeout(function () {             
            $.connection.hub.start();
        }, 5000); // Restart connection after 5 seconds.
    });

    return {
        start: start
    }
})();

Upvotes: 1

Views: 1167

Answers (1)

Bangar
Bangar

Reputation: 43

Upgrade SignalR to 2.1.0+ to solve the issue.

Upvotes: 2

Related Questions