Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1879.
DISCONNECT Session Expiry Interval currently loses the distinction between absent and zero. Nonzero replacements affect the persistence decision but not the session's expiry timer, and resumed sessions keep the first CONNECT's expiry. Preserve property presence and keep the session's effective interval in sync with the current connection and valid DISCONNECT replacement.
MQTT 5.0 section 3.14.2.2.2 defines absent-versus-zero behavior, rejects duplicates and prohibits changing CONNECT expiry zero to a nonzero DISCONNECT expiry. The latter now receives DISCONNECT Protocol Error and is not treated as a valid clean disconnect. Server-generated DISCONNECT packets omit this client-only property [MQTT-3.14.2-2]. Session persistence follows [MQTT-3.1.2-23].
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html
Compatibility: existing uint property signatures remain unchanged. HasSessionExpiryInterval is added to the packet/options; assigning SessionExpiryInterval, including zero, marks it present. Leave it unset or clear the flag to omit it. WithSessionExpiryInterval(0) now sends explicit zero. The convenience DisconnectAsync overload keeps its existing optional zero-as-absent behavior; use options to request explicit zero. MQTT 3 session persistence rules are unchanged. The already-nullable exception property now reports null for absence.
Independent reproduction against master 18731d9: CONNECT expiry 30, DISCONNECT expiry 1, reconnect after 2.1 seconds incorrectly reports Session Present. Tests also reproduce explicit-zero loss and stale expiry after session resumption. All four initial negative cases fail against unmodified upstream.
Tests cover expiry replacement (zero, finite, infinity), session-status interval, resumed CONNECT expiry zero/one, explicit-zero roundtrip, absent defaults, builder/factory propagation, duplicate properties, prohibited zero-to-nonzero transition, and omission from server-generated DISCONNECT.
Validation: