I have one load balancer i.e aws elb all the pub/sub will be coming via that elb two mosquitto broker A & mosquitto broker B under elb one mosquitto broker to sync topic between this two brokers(mosquitto.broker.sync)
this is how the configuration for mosquitto broker which sync topics between node A and B looks alike
mosquitto.broker.sync: ##
connection mosquitto-bridge
try_private false
address mosquitto.broker.A:1883 mosquitto.broker.B:1883
start_type automatic
round_robin true
notifications true
topic # both 2 "" ""
But this is not working it only connecting to mosquitto.broker.A and not connecting to mosquitto.broker.B
undo all try one firstly
so I tried it other way round removed all the bridge config from mosquitto.broker.sync (just to avoid loops)
and added this config onto nodes
mosquitto.broker.A: ##
connection mosquitto-bridge
try_private false
address mosquitto.broker.sync:1883
start_type automatic
round_robin true
notifications true
topic # both 2 "" ""
mosquitto.broker.B: ##
connection mosquitto-bridge
try_private false
address mosquitto.broker.sync:1883
start_type automatic
round_robin true
notifications true
topic # both 2 "" ""
mosquitto.broker.sync: ##
#connection mosquitto-bridge
#try_private false
#address mosquitto.broker.A:1883 mosquitto.broker.B:1883
#start_type automatic
#round_robin true
#notifications true
#topic # both 2 "" ""
But in this case the node on which I send the message is been duplicated over it
For the first attempt, the problem is because the address
field is a list of brokers to try and connect to in order, not a list of brokers to be connected simultaneously.
How this list is interpreted depends on the round_robin
setting.
If set to true then the broker will connect to the first in the list and when the connection drops it will try the next in the list, moving down the list on each reconnect.
If set to false it will connect to the first and treat this as the preferred connection. When the connection drops it will try and reconnect, if it fails it will move down the list, but periodically try and reconnect to the fist in the list.
To actually solve your problem try something like this:
mosquitto.broker.A
connection sync-a
try_private false
address mosquitto.broker.sync:1883
notifications true
topic # out 2 "" A/
topic # in 2 "" B/
mosquitto.broker.B
connection sync-b
try_private false
address mosquitto.broker.sync:1883
notifications true
topic # out 2 "" B/
topic # in 2 "" A/
And leave the sync machine as it is.
This uses topic prefixes to ensure no loops are formed. It also means you can keep track of which broker is doing what on the sync machine as all topics are prefixed with the machine they came from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With