IOT Hub Multiple connections on single device

Ben Dimelow 21 Reputation points
2022-06-10T10:50:48.993+00:00

Background: We have multiple applications and windows services that run on our devices at any one time.
We were hoping we could communicate to IOT Hub from each of these services to send and receive messages but ran into this problem: https://learn.microsoft.com/en-us/azure/iot-hub/troubleshoot-error-codes#400027-connectionforcefullyclosedonnewconnection

Is there a way for multiple applications on a single device to each communicate to IOT hub at the same time?

If not what is the suggested practice for doing this?

Would we need to set up an app on the device for communicating with IOT and have each of our applications communicate through this?

This may add complexity and we wouldn't be able to report when this connection cannot be made.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,274 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 36,766 Reputation points MVP Volunteer Moderator
    2022-06-11T11:35:42.45+00:00

    Hello @Ben Dimelow .

    it seems you are reusing the same connection string for a single device multiple times.

    Because the applications are bound to the same device, you obviously want to have single-device registration.

    There are two ways to solve the 'collision'.

    First, check out these module identities you can add to a single device:

    210444-image.png

    Each module is a logical part of the device it is created in. It get's its own credentials:

    210458-image.png

    Add a module identity for each application:

    210494-image.png

    Now, the applications are still transmitting their messages as being part of that single device. Next to the DeviceId, the IoT Hub also exposes the ModuleId:

    210426-image.png

    So, you can still distinguish the separate message 'source'.

    The other solution is checking out Azure IoT Edge.

    If your device is capable of running Docker containers (can it run Moby?) you could move your application logic into Docker containers and use Azure IoT Edge.

    Actually, Azure IoT Edge registers these containers as modules too.

    These are several advantages to checking out the edge.

    In your case, there are two advantages seen as 'low hanging fruit':

    1. modules messages bound for the cloud are stored automatically when the internet connection is not available. Messages are then sent at a later moment, no message loss or homebrew solution needed.
    2. modules are updated from the cloud using the IoT Hub logic (a deployment manifest)
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.