On my MVC4 ASP.NET web page, I have the code below within the javascript for dealing with the connection to the server and re-connection to the server (if connection is lost with the server for some reason).
The trouble is $.connection.hub.start().done()
is not getting called in response to $.connection.hub.start()
for the reconnect (its only getting called when it is issued the first time). Is this a bug I wonder? If not, is there an equivalent way to alert the client that start()
has completed.
// Start the signalR connection and request the default page
$.connection.hub.start().done(function () {
console.info("$.connection.hub.start().done");
hubProxy.server.sendDefaultPage();
});
//if server goes away - reconnect to it
$.connection.hub.disconnected(function () {
console.info("disconnected");
setTimeout(function () {
$.connection.hub.start();
}, 5000); // Restart connection after 5 seconds.
});