Skip to content

Connection states

The ConnectionState enum, as reported by ResilientMqttClient.State and streamed by WatchState.

StateMeaningLeaves via
DisconnectedInitial state, before the first connectConnectAsync
ConnectingFirst connection attempt in progresssuccess → Connected; failure → WaitingRetry; terminal → Faulted
ConnectedA session is livedrop → Reconnecting; DisconnectAsyncStopped
ReconnectingThe connection was lost; restoringsuccess → Connected; failure → WaitingRetry
WaitingRetryBacking off between attemptstimer → Connecting/Reconnecting
FaultedTerminal failure; stickyexplicit ConnectAsync
StoppedStopped at the caller's requestConnectAsync

Notes:

  • Connected is only entered after the lifecycle hook ran (re-subscription) and the offline queue flushed — by the time you observe it, the session is fully restored.
  • Faulted and drop transitions carry broker or connection details on ConnectionStateChanged — for example SessionTakenOver after a broker DISCONNECT, or NotAuthorized after a rejected CONNECT.
  • Health checks map these as healthy (Connected), degraded (Connecting, Reconnecting, WaitingRetry), and unhealthy (the rest).

ConnectionStateChanged — the WatchState element:

FieldMeaning
Previous / CurrentThe transition
AttemptThe connection attempt number, for retry telemetry
ReasonThe broker's reason code, populated on drops and faults when one is known
ReasonStringMQTT 5 reason string text, when the broker supplied it
ServerReferenceMQTT 5 server reference, useful for redirect-aware deployments
ErrorThe triggering exception for rejected connects, retry failures, disconnects, and terminal faults

ResilientMqttClient.GetDiagnosticsSnapshot() gives the same state as a synchronous snapshot for dashboards and support tools:

FieldMeaning
ClientId, State, Attempt, IsRunning, StateChangedAtCurrent lifecycle state
LastReason, LastReasonString, LastServerReference, LastErrorLast known broker or fault detail
OfflineQueueDepth, OfflineQueueDroppedCountOffline queue counters, or null if a custom store cannot report them
SubscriptionCount, PendingSubscribeCount, PendingUnsubscribeCountSubscription bookkeeping
BrokerCapabilitiesCurrent negotiated broker capabilities while connected; null in disconnected, retrying, stopped, or faulted states

Released under the MIT License.