Skip to content

Add MQTT auto-reconnect with exponential backoff#151

Merged
1technophile merged 1 commit into
developmentfrom
fix/mqtt-auto-reconnect-backoff
Jun 29, 2026
Merged

Add MQTT auto-reconnect with exponential backoff#151
1technophile merged 1 commit into
developmentfrom
fix/mqtt-auto-reconnect-backoff

Conversation

@1technophile

Copy link
Copy Markdown
Member

Description:

QMqttClient does not reconnect on its own, so an unexpected disconnect (broker restart, transient network drop) left the app stuck on the "broker disconnected" banner until the user manually tapped retry — while every other MQTT client on the network self-heals.

MqttManager now arms a single-shot QTimer on entering the Disconnected state and re-dials with exponential backoff (2s base, 60s cap), resetting on a successful connect. An m_reconnectWanted intent flag gates the timer so an explicit disconnect() / MQTT-off never triggers an unwanted re-dial. The Disconnected hook also covers failed reconnect attempts, so the backoff keeps escalating until the broker returns.

Checklist:

  • The pull request is done against the latest development branch
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • I accept the DCO.

QMqttClient does not reconnect on its own, so an unexpected disconnect
(broker restart, transient network drop) left the app stuck on the
"broker disconnected" banner until the user manually tapped retry —
while every other MQTT client on the network self-heals.

MqttManager now arms a single-shot QTimer on entering the Disconnected
state and re-dials with exponential backoff (2s base, 60s cap), resetting
on a successful connect. An m_reconnectWanted intent flag gates the timer
so an explicit disconnect() / MQTT-off never triggers an unwanted re-dial.
The Disconnected hook also covers failed reconnect attempts, so the
backoff keeps escalating until the broker returns.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@1technophile
1technophile merged commit d203e28 into development Jun 29, 2026
8 checks passed
@1technophile
1technophile deleted the fix/mqtt-auto-reconnect-backoff branch June 29, 2026 00:28
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.

1 participant