0
votes

I'm an MQTT newbie, so maybe this is obivous but I'm not getting it.

I've got IoT devices that publish data to a cloud MQTT broker. I can't change that. I want to be able to get the messages from the cloud broker and pass them to IoT Hub in Azure. Here's what I've done so far:

  1. Configured a VM running CentOS to host my Mosquitto server
  2. Installed Mosquitto and configured as a bridge to IoT Hub (IoTHubBridge)
  3. Created a separate Mosquitto config to bridge to the cloud MQTT broker (CloudBridge)

Note that both Mosquitto bridge instances are running on the same VM.

So far, so good. IoT Hub can receive test messages that pass through IoTHubBridge and CloudBridge receives messages from the cloud broker. Here's where I'm stuck - how do I get messages to pass from CloudBridge to IoTHubBridge?

Thanks!

1
Why do you have 2 brokers? You can configure multiple bridges for a single broker.hardillb
like I said - newbie. I was thinking each bridge had to be a separate Mosquitto instance. Are you saying put the configuration for both bridges in the main mosquitto.conf file?auaero
Ok, I see where you're going. I've got both bridges set up in the mosquitto.conf file and I'm receiving messages from CloudBridge and I get send messages with mosquitto_pub to IoT Hub through IoTHubBridge. I'm still stumped on the original question - how can I have IoTHubBridge send messages to IoT Hub that are being received by CloudBridge?auaero
You don't do anything, if you've got the bridge configurations right messages will just flow straight through your bridge broker to where they need to go based on the topic mappingshardillb

1 Answers

0
votes

As hashed out in the comments.

There is no need for 2 MQTT brokers here. You should configure both bridges in a single broker, that way with the right topic declarations for the bridges messages should just flow between the IoT Hub and Cloud brokers.

This does assume that the topic/message structure for the cloud broker is compatible with what you need to send to IoT hub. The bridge will allow you to add/remove a prefix from the topic but not totally remap it. And there is no way to change the payload format.

If you need to make changes to the payload format or major changes to the topic structure then a bridge is not the right solution. You will need to create an application that subscribes to the cloud broker and then republishes the transformed message to the IoT Hub broker. There are many ways to do this in any number of languages but I might suggest you look at something like Node-RED if you are not already comfortable with an existing language/MQTT client combination.