Multiple connections to IoT Hub devices

Slava A 106 Reputation points
2020-11-17T14:35:43.747+00:00

This is related to https://learn.microsoft.com/en-us/answers/questions/148853/restrictions-on-deviceclient.html
Opening a second connection to a device generates exceptions and both connection don't work.

  1. is it possible for SDK to internally manage connections and automatically disable "old" connection when new connection is created
  2. if one of the connections is closed, the other seems to reconnect and starts to work. is there a timeout associated with this reconnect? or it will try to reconnect until it succeeds?
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,273 questions
Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
228 questions
{count} votes

3 answers

Sort by: Most helpful
  1. António Sérgio Azevedo 7,671 Reputation points Microsoft Employee Moderator
    2020-11-18T17:46:10.677+00:00

    Hello @Slava A ,

    !Please understand that as mentioned in the related thread, the scenario of "opening a second connection to a device" is unsupported and exceptions\errors you receive are expected.

    1) is it possible for SDK to internally manage connections and automatically disable "old" connection when new connection is created

    If you can recognize the new connection created with the exception or error thrown by the SDK then you can "manipulate" SDK behavior based on that. See 400027 ConnectionForcefullyClosedOnNewConnection

    PS: I am validating internally if this also applied when you connect with AMQP transport type.

    2) if one of the connections is closed, the other seems to reconnect and starts to work. is there a timeout associated with this reconnect? or it will try to reconnect until it succeeds?

    It will retry based on the retry policy: https://github.com/Azure/azure-iot-sdk-java/blob/master/device/iot-device-client/devdoc/requirement_docs/com/microsoft/azure/iothub/retryPolicy.md

    Thanks!

    Remember:

    • Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification.
    1 person found this answer helpful.

  2. Liam Sanchez-Rodriguez 1 Reputation point
    2022-01-14T16:03:21.403+00:00

    Hi, did you solve your issue? I am having the same issue when sending telemetry data from Python SDK on a RaspberryPi 4, and try to receive the cloud-to-device message on the Python SDK running on my laptop, when both connections happen at the same time, both terminals begin to throw 'Connection dropped' errors

    0 comments No comments

  3. mani_km 1 Reputation point
    2022-07-25T12:28:20.717+00:00

    Hi Liam

    similar to your issue i am also facing, i have to wait for desired property and i need update the reported data & telemetry data every 5 second need to send when i am connecting any two also i m also getting same connection dropped error

    exact screen error

    "Exception caught in background thread. Unable to handle.
    ['azure.iot.device.common.transport_exceptions.ConnectionDroppedError: Unexpected disconnection\n']"

    if you solve please help me & reply to this

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.