MQTT State transitions Andrew Banks MQTT V 3
MQTT State transitions Andrew Banks
MQTT V 3. 1. 1 State transitions Void Connect Connack returns Session. Present=false Session Exists (connected) Connect Disconnect from clean. Session=false Network break clean. Session = false Connack returns Session. Present=true from clean. Session=false Session Exists (disconnected) Connect clean. Session=true (and creates a NEW session) Send Will Disconnect from clean. Session=true, or Session State is empty. Network break from clean. Session=true or Session State is empty Void Send Will
MQTT V 5 State transitions Void Connect Connack returns Session. Present=false Session Exists (connected) Connect clean. Start = false Connack returns Session. Present=true Network break Disconnect Session Exists (disconnected) Send Will, if Will on Session expiry NOT set Session Timer, from Connect or Disconnect Session State exists, even if empty. Connect clean. Start=true (and creates a NEW session) Void Send Will, if Will on Session expiry IS set
Proposal The DISCONNECT packet has an optional Session State Expiry Interval, if present this overrides the value set on CONNECT. Clean Session is renamed to Clean Start, this causes any existing Session State to be deleted on CONNECT but not on DISCONNECT. A new flag Send. Will. On. Session. State. Expiry, is sent as a CONNECT optional value. If absent or false the will message is sent on network disconnection where no DISCONNECT packet is processed as today. If true the Will message is sent on Session Expiry, regardless of how this occurs. Or A new flag Will. Delay, is sent as a CONNECT optional value. If absent the will message is sent on network disconnection where no DISCONNECT packet is processed as today. If present the Will message is sent after the specified interval so long as no new CONNECT is processed first. The Server retains knowledge of the Session for the duration of Session Expiry, even if the Session Contains no Messages or Subscriptions.
Send. Will. On. Session. State. Expiry vs Send. Will. Delay • Will. Delay must be less than Session. State. Expiry. Interval, otherwise you get a zombie Will message with no associated Session State. • This rule is hard to enforce if the Session. State. Expiry. Interval is reset on DISCONNECT.
- Slides: 5