Bridges are essentially a way for one MQTT broker to connect to another MQTT broker. This is a very useful feature and enables you to setup your own HA "cluster".

You can create your own bridge from the console page.

In the "Connection uri" field you must enter a connection string in this format: mqtt://USER:PASSWORD@host:port If you don't enter a port the default 1883 will be used.

In the "Direction" dropdown you can choose between:

  • Out - the local broker will forward all messages to the remote broker.
  • In - the local broker will subscribe to all topics on the remote broker.
  • Both - combining in and out.

With the 'Both' option you can create loops. This means that the brokers are forever forwarding each other the same message.

To get around the loop problem you can specify a "Local prefix" and a "Remote prefix". Local in this context means the broker where the bridge is defined. This means that only a topic that matches the prefix will be forwarded.

We have two brokers, A and B, where A is the local broker hosted by CloudMQTT.

On the console page we enter the connection options to broker B and select the direction "both". We then enter "B/" into the "Local prefix" field. We enter "A/" into the "Remote prefix" field.

Then we publish the current time to the topic "A/time" on broker B. On broker A you can subscribe to "B/time" and you will see the times published to broker B. This works in both directions.