We are trying to use SignalR in a low-bandwidth environment, where the connection to the backend server can happen and go randomly, and we want our web application to respond appropriately.
It looks like this communication API was last year, but according to the latest documentation, I tried to connect to $ .connection.hub.stateChanged to detect changes in the connection status, and I get the pair to start at startup when the client switches from disconnected -> connection -> connected, but when I stop the server, the event handler does not start, and when I start the server again, real-time messaging no longer works.
To test this scenario, I am on Windows 7 with an ASP.NET web server in IIS, and the web client is running on Google Chrome. After the site is started and messaging, I kill the website in IIS, and the messages stop, but the client does not receive any notifications.
Here is a quick snippet (using TypeScript):
$.connection.hub.stateChanged((change) => {
console.log("state changed...");
console.log(change);
if (change.newState === $.signalR.connectionState.reconnecting) {
this.raise('action:disconnected');
}
else if (change.newState === $.signalR.connectionState.connected) {
this.raise('action:connected');
}
});
Any guidance would be greatly appreciated, thanks!
-Jeremy
source
share