I'm trying to detect when a SignalR Core connection is lost so that I can create a new one or at least warn the user.
connection.on('closed', data => {
alert('Connection Closed');
});
This seems to have no effect. The messages stop arriving but this handler isn't fired.
On a related note, where is the documentation for event handling for the new version of this library?
If a server does not become available within the disconnect timeout period, the SignalR connection ends. In this scenario, the Closed event ( disconnected in JavaScript clients) is raised on the client but OnDisconnected is never called on the server.
In the default mode, the app server creates five server connections with Azure SignalR Service. The app server uses the Azure SignalR Service SDK by default. In the following performance test results, server connections are increased to 15 (or more for broadcasting and sending a message to a big group).
SignalR requires that all HTTP requests for a specific connection be handled by the same server process. When SignalR is running on a server farm (multiple servers), "sticky sessions" must be used. "Sticky sessions" are also called session affinity by some load balancers.
Use onclose
:
connection.onclose(function (e) {
alert('Connection Closed');
}
There's no documentation yet, but a handful of samples on GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With