IoT Hub as MQTT Broker

Red255 71 Reputation points
2022-01-21T15:12:27.183+00:00

I am aware IoT Hub is not a fully featured MQTT broker. However - I would like to try and understand how this will limit my use of MQTT in my application.

My devices publishes and subscribes MQTT topics - will IoT Hub accept the MQTT telemetry messages my device publishes if I simply connect it to the hub? (is there anyway to view the messages received by IoT Hub?)

If I publish a topic from another device and another device is subscribing to this topic will it receive it? If I can not do this can I create an API that 'feeds' into the IoT Hub to do this?

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

Accepted answer
  1. Sander van de Velde | MVP 36,766 Reputation points MVP Volunteer Moderator
    2022-01-21T16:01:32.563+00:00

    Hello @Red255 ,

    you want to check if messages are actually arriving in the IoT Hub.

    Yes, this is easy.

    The most simple way is to install the Azure IoT Explorer.

    The installer of this visual tool is found here.

    Add a connection to your IoT Hub by supplying the IoT Hub Owner connection string.

    Regarding the topics, please keep everything in one place. Devices must be handled as atomic entities.

    If you want to send a message from one device and react to it using another, build this logic into the backend, behind the IoT Hub. A possible solution is adding an Azure Function responding to incoming messages.

    Once submitted, the list of devices is shown.

    Select your device and select telemetry:

    167292-image.png

    Select start and you are able to see incoming messages.

    One more thing: this uses the $default consumer group. This means your tool now tries to access the same 'copy' of the messages which are normally sent to the systems behind the IoT Hub.

    This can end up in a collision.

    Please add a separate Azure IoT Hub consumer group, there are no extra costs involved.


1 additional answer

Sort by: Most helpful
  1. Red255 71 Reputation points
    2022-01-24T15:21:13.11+00:00

    I think I have manged to successfully connect my hardware device, but as soon as it publishes anything the IoT hub disconnects it? I am trying to use Azure IoT explorer to monitor the telemetry being sent but I am not seeing anything. I have tried with the tutorial on this page https://learn.microsoft.com/en-us/azure/iot-hub/quickstart-control-device?pivots=programming-language-csharp but even though I can see 'MyDotNetDevice' it is not showing any telemetry data. If I look at my IoT hub in Azure I can see the message count increasing so I know it is working.

    1 person found this answer helpful.
    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.