Skip to content

fix(mqtt): keep reconnecting after a session takeover - #69

Merged
stakach merged 1 commit into
masterfrom
fix/mqtt-reconnect
Oct 27, 2026
Merged

stakach merged 1 commit into
masterfrom
fix/mqtt-reconnect

Conversation

@stakach

@stakach stakach commented Oct 27, 2026

Copy link
Copy Markdown
Member

Problem

Source opened a new MQTT connection while its old one was still open, the broker took the session over, then disconnected the new connection with a protocol error, and source never tried again.

Fix

  • Bump mqtt to 2.0.2:
    • a reconnection that drops straight away is retried instead of terminating the client
    • a protocol error or malformed packet disconnect no longer vetoes reconnecting
    • only CONNECT/AUTH/DISCONNECT are written until the broker sends the CONNACK (closed? stays true until then); previously the resync published ahead of the CONNACK
    • keepalive is bound to its own transport
    • new on_reconnect callback
  • MqttPublisher resyncs from on_reconnect rather than counting transports
  • Logs an error when the client stops for good, skipped when the manager replaces a publisher (that takeover is intentional)
  • BrokerRelay moved into spec_helper and gained drop; new spec for resyncing after a reconnection

Testing

Specs run in three batches (the full single run is OOM killed in the local Docker VM, master behaves the same): 79 examples, 0 failures.

🤖 Generated with Claude Code

Bump mqtt to 2.0.2, which keeps retrying when a reconnection drops straight
away or the broker reports a protocol error, and holds application packets
until the broker accepts the connection.

Resync from the client's on_reconnect callback, once the broker has accepted
the new connection, instead of counting transports. Log an error when the
client stops for good, except when the manager replaces a publisher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the type: bug something isn't working label Oct 27, 2026
@stakach
stakach merged commit a567213 into master Oct 27, 2026
11 checks passed
@stakach
stakach deleted the fix/mqtt-reconnect branch October 27, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant