MQTT Session State Manager
Inspect the broker-side session records that make MQTT reconnects reliable or risky.
MQTT Session State Manager
An MQTT connection is the live network link. An MQTT session is the remembered state tied to a ClientID. Use this workbench to inspect what the broker keeps, discards, resumes, or cleans up when IoT devices disconnect and reconnect.
The TCP or WebSocket connection can drop, while the MQTT session record may remain at the broker.
To resume a session, the reconnecting device must use the same ClientID and compatible clean-session settings.
Subscriptions and QoS 1/2 delivery state can survive. Retained messages are a separate topic-level feature.
If the CONNACK says no session was present, the client should rebuild subscriptions and local assumptions.
Trace a reconnect from the broker's point of view
Step through the sequence. Watch the session shelf, the CONNACK result, and the broker pressure signal change together.
Try common broker decisions
Change the session request
Incoming CONNECT
Broker session registry
State drawer
The ClientID matches, the request asks to resume, and the expiry window has not elapsed. The client can rely on Session Present and process queued QoS 1/2 messages.
Clean Start decides whether to begin with old state. Session Expiry decides how long state survives after disconnect.
Clean Session 1 starts clean. Clean Session 0 asks the broker to resume and store session state after disconnect.
Random ClientIDs create new shelves at the broker, so old subscriptions and queues become unreachable orphans.
If it is 0, rebuild subscriptions. If it is 1, the broker accepted an existing session for that ClientID.
Technical notes and primary sources
This workbench keeps retained messages separate because retained messages belong to topics, not to one client's session queue.
MQTT 5 allows broker discretion in some storage behavior, but portable offline reliability should use subscriptions and QoS 1 or QoS 2.
The broker closes the old connection. This can be useful for failover, but accidental duplication can kick active devices offline.
Set expiry, queue limits, and cleanup policies so abandoned devices do not consume broker memory or disk forever.
Practice prompts
Which settings let it receive QoS 1 command messages after reconnect without creating long-lived abandoned sessions?
Check Session Present first. If it is 0, the client must resubscribe instead of assuming the broker still has state.
Look for random ClientIDs, missing expiry limits, and offline queues that outlive the business value of the messages.
Use stable ClientIDs, persistent sessions, QoS 1/2 publishing, and broker limits sized for the expected outage window.