Search code examples
mqttmosquittopaho

Is there any way can sync client state between 2 MQTT broker


Hi I am building 2 mosquitto MQTT brokers on 2 separate device with bridge setting in between. And both brokers are set persistent that can store the messages. Let say broker A and broker B. When I publish message on Topic A to broker A, I can get the message on both brokers when I subscribe Topic A on both brokers. But now I am facing is when I continuously publish messages on Topic A, let say 100 messages, the broker can recognize the client state on 1 broker but not both.

For example:

Client with clientid client1 subscribe Topic A on broker A, it receive message and stop the script after received 50 messages. When the client restart the script, it receive message from 51 and stop again after received message 70.
Then the client subscribe Topic A on broker B with clientid client1, it receive message from 1.

Is there any way that can sync the client state between 2 brokers? Like from above example, client receive message from 71 when subscribe Topic A on broker B.

Thank you.


Solution

  • No, mosquitto has no mechanism for session synchronisation.

    There are a number of other MQTT brokers that use backend databases to store session information so all the session information is shared between load balancing/HA brokers.