Search code examples
mqttazure-iot-hubazure-iot-edge

Azure IoT Hub - Publish and subscribe to same MQTT topic


I want to publish a message to IoT Hub and also receive the message via the same topic. I connected to IoT Hub and then subscribed to the same topic to which i send the messages, but I don't receive any message. As Client I am using MQTTX windows. Messages are sent and received correctly at the cloud endpoint (telemetry data).

Here is a screenshot from my MQTT client: MQTT Client


Solution

  • I see you are using MQTTX as a leaf device to IoT Edge in a transparent gateway pattern, where edge will just pass through messages to IoTHub.

    IoTHub does not support custom topic or respond back on the same topic so this "devices/plc2/messages/events/topic" will not work

    Subscription to devices/{device_id}/messages/devicebound/# will work but you will need to explicitly send C2D message for that device_id as a response