Skip to content

fix(mqtt): Surface clean-session reconnect on Subscription::next_message#123

Merged
MathiasKoch merged 5 commits into
masterfrom
feat/subscription-disconnect-aware
May 5, 2026
Merged

fix(mqtt): Surface clean-session reconnect on Subscription::next_message#123
MathiasKoch merged 5 commits into
masterfrom
feat/subscription-disconnect-aware

Conversation

@KennethKnudsen97

Copy link
Copy Markdown
Contributor

Summary

  • MqttSubscription::next_message returns None when the broker has dropped our subs (CONNACK with session_present=false), so callers can resubscribe.
  • mqttrust backend: bumps to fix: Detect clean-session reconnects in Subscription::next_message mqttrust#81 which implements the signal via clean_session_count.
  • rumqttc backend: same semantic via a watch::Sender<u8> counter bumped only on session_present=false CONNACKs. Replaces the previous over-aggressive "any state change → None".
  • Trait doc clarified.

Test plan

  • Hardware test (mqttrust backend): clean-session reconnect → wait_delta returns None → caller resubscribes.
  • Transient disconnect & session-resume reconnects keep subscriptions valid.
  • Add an end-to-end test covering the rumqttc path.

Fixes #121

Kenneth Sylvest Knudsen and others added 4 commits May 1, 2026 10:13
…opics

Bump the QoS on the request/response topic pairs from AtMostOnce to
AtLeastOnce so a transient drop between SUBSCRIBE and the broker's reply
doesn't silently lose the response and park the caller forever.
Watch the broker connection state from each Subscription so an
ungraceful drop wakes parked next_message() callers with None instead
of hanging forever. rumqttc impl uses tokio::sync::watch.

Builds on #122. Issue #121.
Only invalidate Subscriptions when the broker actually drops our subs
(CONNACK with session_present=false). Transient disconnects and
session-resume reconnects keep subs valid.

- mqttrust backend: bump rev to pick up FactbirdHQ/mqttrust#XX, which
  surfaces the same signal via clean_session_count.
- rumqttc backend: track a watch::Sender<u8> bumped only on
  session_present=false; subscriptions race recv against changed().
  Replaces the over-aggressive "any state change → None" behavior.
- Trait doc clarified.

Refs #121
@MathiasKoch
MathiasKoch merged commit e568a3d into master May 5, 2026
5 checks passed
@MathiasKoch
MathiasKoch deleted the feat/subscription-disconnect-aware branch May 5, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shadow update_shadow / get / delete hang permanently after MQTT disconnect

2 participants