← Back to team overview

mosquitto-users team mailing list archive

Bridges, persistence and retained messages (might be a bug)

 

Problem: Messages are not being retained under some circumstances when
persistence is being used.

Setup:

Mosquitto 1.2.3

BROKER A   <-- BRIDGE -->  BROKER B

The bridge is initiated from Broker B.

Config A

  persistence true
  persistence_file mosquitto-A.db
  persistence_location /tmp/
  autosave_interval 3600

  port 1883


Config B

  persistence true
  persistence_file mosquitto-B.db
  persistence_location /tmp/
  autosave_interval 3600

  port 1884

  connection A
  address 127.0.0.1:1883
  topic # both


When starting with no persistence files it works as we expects.

Setting a retained message on either A or B makes it retained on both
brokers.

Setting on A and B

  $ mosquitto_pub -p 1883 -t retainedA -m test -r
  $ mosquitto_pub -p 1884 -t retainedB -m test -r

Verifying that the messages are retained.

  $ mosquitto_sub -p 1883 -t \# -v
  retainedA test
  retainedB test

  $ mosquitto_sub -p 1884 -t \# -v
  retainedA test
  retainedB test

Works as expected.

Removing the retained messages by sending a null-message to the topics
also works as expected.

But, restarting the brokers (making them read the persistence database)
makes it behave different.

  $ mosquitto_pub -p 1883 -t retainedA -m test -r
  $ mosquitto_pub -p 1884 -t retainedB -m test -r

  $ mosquitto_sub -p 1883 -t \# -v
  retainedA test
  retainedB test

  $ mosquitto_sub -p 1884 -t \# -v
  retainedB test

Only the retained message set directly on B is set on B. Also remove
retained topics on B via the bridge does not work.

This was little hard to find since it only occurs after restarting with
a persistence file present.

Is this a bug or did we do something wrong?

Regards

Marcus

-- 
Marcus Rejås
ALLEATO
Tel. +46 176 250103
Mobilnr: +46 70 266 79 85
marcus.rejas@xxxxxxxxxx
http://www.alleato.se


Follow ups