MQTT Message Structure

Red255 71 Reputation points
2022-01-24T16:41:19.14+00:00

After some experiments with IoT Hub and my legacy MQTT devices I have found that as they do not publish messages exactly as IoT hub requires the connection gets dropped.

Our MQTT message structure follows typical MQTT layout 'DEVICE_ID/TOPIC/SUB_TOPIC' then data payload {"data1":"text value", "data2",127}

But IoT Hub appears to require 'devices/DEVICE_ID/messages/events/TOPIC/' it appears happy with the payload but it does not like a 'SUB_TOPIC'

I can not make any changes to my legacy products so my question is how can I connect then to IoT hub - will protocol gateway help me?

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
598 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,271 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. António Sérgio Azevedo 7,671 Reputation points Microsoft Employee Moderator
    2022-01-25T13:18:39.443+00:00

    Hello @Red255 ,
    As you well described and if we read the documentation Communicate with your IoT hub using the MQTT protocol , IoTHub won't accept 'SUB_TOPIC' when sending device-to-cloud messages!

    When not able to make any changes to your brownfield\legacy devices then yes, Azure IoT protocol gateway will help you! If you want to keep it on the edge you can leverage Azure IoT Edge acting as an MQTT broker.

    You can use Azure IoT Edge MQTT broker to publish and subscribe to messages. ... publish and subscribe to messages over user-defined topics, and use IoT Hub messaging primitives

    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.
    0 comments No comments

  2. Eduardo Guido Flores Pascual 1 Reputation point
    2022-10-12T23:57:40.34+00:00

    Hello! @António Sérgio Azevedo , I have a question, I know the structure for the topic is "devices/DEVICE_ID/messages/events", without TOPIC, at least it is in the docummention https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support, but the tests that were done by @Red255 tells us that we can use an extra word in the topic structure, could you confirm this information? Because if this is correct, the docummentation should be updated.


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.