Bridging an MQTT broker to 2 remote MQTT brokers simultaneously
Asked Answered
H

2

5

We have many local gateways installed at different premises. These gateways will host an MQTT broker for connecting all the local services. Then it is required that the local MQTT broker sends this data to two remote MQTT brokers (each hosted with a different party). I have read the documentation on Mosquitto and VerneMQ brokers and I see that they only allow one remote server to be bridged at a time.

Is there another (open source) broker which provides such functionality? If not how can we achieve this?

Huntlee answered 26/2, 2018 at 6:41 Comment(0)
D
8

You can declare are many bridges as you want with mosquitto.

From the mosquitto.conf man page:

Configuring Bridges

Multiple bridges (connections to other brokers) can be configured using the following variables.

You just have multiple blocks starting with connection

connection test-mosquitto-org
address test.mosquitto.org
cleansession true
topic clients/total in 0 test/mosquitto/org $SYS/broker/

connection foo.broker.org
address 192.168.1.1
topic # both 0
Dilatometer answered 26/2, 2018 at 7:56 Comment(3)
So in that case, the local broker will publish selected topics to all the bridged brokers ? So based on your example, it will be both test.mosquitto.org and 192.168.1.1?Huntlee
yes, but the topics published/subscribed to is different based on the topic line in each config block. Look at the linked to doc for detailsDilatometer
The part that I missed in the documentation was that I could specify multiple connection names that establishes multiple bridges. That and the option of specifying multiple addresses for fallback confused me and I could not see how multiple simultaneous brokers can be setup. Thanks.Huntlee
B
1

Thanks hardillb. Also in my case I used clients ids, obviously they need to be unique per bridge block:

e.g.

connection solace.cloud
address <mqtt address>:<port>
remote_username <username>
remote_password <password>
clientid Alpha
try_private false
start_type automatic
topic Nasdaq/ out 0 b1/ ""
topic Nasdaq/ in 0 "" b2/

connection cloudmqtt
cleansession true
address postman.cloudmqtt.com:<port>
remote_username <username>
remote_password <password>
clientid Beta
try_private true
start_type automatic
topic Nasdaq/# out 0
topic Nasdaq/# in 0
Battology answered 22/1, 2020 at 22:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.