Signal R randomly loses connection to the server side

We are using Signal R with Azure Web App in ASE for our live web app. We have noticed that Signal R sometimes loses connection to a hub in any particular circuit. This happens during both high traffic periods and low traffic levels, but I'm more interested in why this happens during low traffic periods. Note. We have a so called "1 minute auto refresh" which is triggered by JavaScript on the page. It seems to work.

Has anyone encountered similar issues using SignalR, and if so, how did you resolve it?

Thank. (tester, not too harsh! lol)

+3


source to share


1 answer


I definitely experienced this and it drove me crazy.

By default, the SignalR client will try to reconnect for 20 seconds after losing connection to its hub. After 20 seconds without successfully reconnecting, the disabled event is raised on JavaScript clients. After disconnecting, the client will stop trying to connect and the connection will be dead. This page describes the SignalR lifecycle events and provides some code when trying to reestablish a connection after the event is disabled.



Now why is this happening. I noticed that in some applications, it can take longer than 20 seconds for the application to restart, which could result in a disabled event. This can sometimes cause a short-term drop in the network connection between your JavaScript clients and the hub that lasts more than 20 seconds. The bottom line is that things can go wrong, which is uncontrollable and you cannot code them. Therefore, create logic to try to reconnect after the JavaScript client receives a disconnected event.

0


source







All Articles