Reputation: 581
i noticed that in a ASP.Net Web Forms SignalR implementation the clients loses connection after ~30 minutes and then there is a storm of reconnects and failures as connect id is not valid.
How could I limit this number or rate of retries?
Thank you in advance
Upvotes: 1
Views: 1805
Reputation: 1142
I think a possible solution as a found in a learn.microsoft.com article
In some applications you might want to automatically re-establish a connection after it has been lost and the attempt to reconnect has timed out. To do that, you can call the Start method from your Closed event handler (disconnected event handler on JavaScript clients). You might want to wait a period of time before calling Start in order to avoid doing this too frequently when the server or the physical connection are unavailable.
in Javascript
$.connection.hub.disconnected(function() {
setTimeout(function() {
$.connection.hub.start();
}, 25000); // Restart connection after 25 seconds.
});
so you can use something like that and try to raise the time parameter for not so frequent reconnections
Upvotes: 1