Skip to content

fix(iot-dev): avoid MQTT cast during reconnect - #1855

Open
Arnab Nandy (arnabnandy7) wants to merge 1 commit into
Azure:mainfrom
arnabnandy7:fix/mqtt-reconnect-class-cast
Open

fix(iot-dev): avoid MQTT cast during reconnect#1855
Arnab Nandy (arnabnandy7) wants to merge 1 commit into
Azure:mainfrom
arnabnandy7:fix/mqtt-reconnect-class-cast

Conversation

@arnabnandy7

Copy link
Copy Markdown

Checklist

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 DISCONNECTED while its device state remained DISCONNECTED_RETRYING. This caused the reconnect flow to treat the MQTT connection as a multiplexed AMQP connection and cast MqttIotHubConnection to AmqpsIotHubConnection, resulting in a ClassCastException.

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:

  • Non-multiplexed transports ignore device-session reconnect state.
  • Multiplexed transports continue to honor device-session reconnect state.

Targeted test results:

Tests run: 74, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.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

1 participant