auaero
auaero

Reputation: 3

Mosquitto - subscribe to topics on a local bridge

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!

Upvotes: 0

Views: 1026

Answers (1)

hardillb
hardillb

Reputation: 59751

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.

Upvotes: 0

Related Questions