fix(iot-dev): avoid MQTT cast during reconnect - #1855
Open
Arnab Nandy (arnabnandy7) wants to merge 1 commit into
Open
fix(iot-dev): avoid MQTT cast during reconnect#1855Arnab Nandy (arnabnandy7) wants to merge 1 commit into
Arnab Nandy (arnabnandy7) wants to merge 1 commit into
Conversation
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
Arnab Nandy (arnabnandy7)
requested review from
Avishek (avishekpant),
Maxim Semenov (maximsemenov80),
olivakar and
Tim Taylor (timtay-microsoft)
as code owners
August 8, 2026 16:31
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.
Checklist
mainbranch.Reference/Link to the issue solved with this PR (if any)
Fixes #1853
Description of the problem
Non-multiplexed clients maintain a device connection state entry for status tracking. The reconnect logic checked this state regardless of whether the transport was multiplexing.
During a close/reconnect race, an MQTT client's transport-level status could be
DISCONNECTEDwhile its device state remainedDISCONNECTED_RETRYING. This caused the reconnect flow to treat the MQTT connection as a multiplexed AMQP connection and castMqttIotHubConnectiontoAmqpsIotHubConnection, resulting in aClassCastException.Description of the solution
Updated
IotHubTransport.needsReconnect()so that device-session reconnect states are checked only when the transport is multiplexing. Transport-level reconnection behavior remains unchanged for non-multiplexed clients, while AMQP multiplexing continues to reconnect individual device sessions as before.Added regression tests verifying that:
Targeted test results: