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?

maulik13
  • 3,656
  • 1
  • 25
  • 36

2 Answers2

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
hardillb
  • 54,545
  • 11
  • 67
  • 105
  • 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? – maulik13 Feb 26 '18 at 08:32
  • 1
    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 details – hardillb Feb 26 '18 at 08:38
  • 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. – maulik13 Feb 26 '18 at 08:49
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
CMP
  • 1,170
  • 12
  • 11