Identifying SignalR transition from "ConnectionSlow" state to normal state

This document from the official doc is a very good start for understanding SignalR events and event states. But something seems to be missing: how can I determine the moment when it connectionSlow

switches to normal state?

I want to show a message to the user when an event is triggered connectionSlow

. But I don't know when to hide this message:

  • If the event is reconnecting

    fired, no problem: I just need to wait for the event Reconnected

    or Closed

    and then either hide the message or show the fatal error.
  • If the event reconnecting

    does NOT fire, perhaps because the connection returns to a "healthy" state without having to reconnect ==> what should I use to identify this?

I started working with a class HubConnection

and its StateChanged

, but the ConnectionState

enum is stateless connectionSlow

.

+3


source to share


1 answer


As you noticed, ConnectionSlow is not a state, it is just an event that indicates that the SignalR client missed the expected save messages.

By default, if the client does not receive any save rights for ~ 7 seconds after starting ConnectionSlow, it will start trying to reconnect. So if the client doesn't start reconnecting within 10 seconds of bypassing ConnectionSlow, you can safely assume that SignalR received a pending after ConnectionSlow was activated.



This does not necessarily mean that the connection stops being slow, but it does mean that SignalR will wait ~ 13 more seconds without getting another support before re-enabling ConnectionSlow. This means that it takes a total of about 20 seconds without any attacks before SignalR automatically tries to connect again. All of these numbers are reset using the standard 10 second SignalR holdover interval.

See the SignalR documentation on understanding and handling lifecycle events in more detail.

+3


source







All Articles