Skip to content

Adopt Paho MQTT v2 callbacks - #1259

Draft
Carter Tinney (cartertinney) wants to merge 1 commit into
mainfrom
ct/paho-mqtt-v2
Draft

Adopt Paho MQTT v2 callbacks#1259
Carter Tinney (cartertinney) wants to merge 1 commit into
mainfrom
ct/paho-mqtt-v2

Conversation

@cartertinney

@cartertinney Carter Tinney (cartertinney) commented Sep 1, 2026

Copy link
Copy Markdown
Member

Checklist

  • I have read the contribution guidelines.
  • I added or modified tests to cover the change.
  • Public SDK behavior is unchanged, so no devdoc update is required.

Reference/Link to the issue solved with this PR (if any)

None.

Description of the problem

The MQTT transport opted into deprecated Paho callback API v1, producing a deprecation warning for customers on Paho 2.x. It also deferred Paho reconnects with an arbitrary two-hour delay, wrote to the private _thread field, and treated every successful subscribe() call as eventual subscription success even when the broker rejected the SUBACK.

Description of the solution

  • Use callback API v2 for TCP and WebSocket clients and update every callback signature.
  • Document that Paho synthesizes MQTT 5 ReasonCode and Properties callback values for MQTT 3.1.1; keep those Paho API concepts at the callback boundary.
  • Classify v2 CONNACK and disconnect ReasonCode objects by documented semantic names while preserving existing SDK exception classification.
  • Complete rejected SUBACKs with ProtocolClientError; retain completion errors in OperationManager when an ACK races ahead of operation establishment.
  • Set reconnect_on_failure=False, remove the reconnect-delay workaround, and rely on Paho 2.1 callback-safe loop_stop() and _thread_main cleanup instead of assigning _thread directly.
  • Require paho-mqtt>=2.1.0,<3.0.0 and update uv.lock.
  • Add public-client warning-as-error coverage and focused callback, disconnect, cleanup, and early-ACK tests.

Validation

  • Targeted transport, MQTT pipeline-stage, and synchronous client tests: 1213 passed, 3 skipped
  • Black passed
  • Ruff passed
  • git diff --check passed

@cartertinney
Carter Tinney (cartertinney) force-pushed the ct/paho-mqtt-v2 branch 4 times, most recently from 12156e5 to 5548931 Compare September 1, 2026 21:26
@cartertinney
Carter Tinney (cartertinney) marked this pull request as draft September 1, 2026 21:54
Migrate transport callbacks to Paho's version 2 API and classify connection and disconnect reasons by their documented semantics. Propagate broker-rejected SUBACKs through operation tracking, including early acknowledgements, and leave reconnect timing to the SDK.

Remove obsolete reconnect-delay and private thread workarounds now that Paho 2.1 is required.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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