6

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)

TRY ONE

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

TRY TWO

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

2
  • Can you try and explain the problem in your second attempt in some more detail, it's not totally clear what the problem is at the moment.
    – hardillb
    Mar 29, 2016 at 11:55
  • update the question, answer helped me its sorted , i was all adding a dummy topic
    – mOsEs
    Apr 1, 2016 at 7:39

1 Answer 1

6

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.

2
  • Thanks.But, why some one has to do this ? The reason for bringing in second broker(B), is to handle the load that cannot be handled by broker(A) alone. Now the sync broker will breakdown as it's message handling capacity will be equivalent to that of broker(A) alone. Or is the number of simultaneous tcp connections the more important limiting factor for a broker rather than it's message handling capacity ? Apr 2, 2016 at 14:07
  • 1
    This is truly only needed if you need more than 2 client facing brokers. It prevents forwarding loops because if you publish to broker A, it forwards to B which then forwards to C. C only sees the message as coming from B so will forward to A and the message goes round and round. The sync broker will not be working any where near as hard as the other brokers because it only needs to match topics for the other brokers not all the end clients.
    – hardillb
    Apr 2, 2016 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.