JohnL
JohnL

Reputation: 14106

Is there a Mosquitto setting for retaining duplicate messages

Using the Mosquitto broker, I have a single publisher that at times may send a duplicate message topics to various clients. The clients are devices that are not always on-line and so when they do connect to the broker, they need to be able to get all of the messages that have been retained. What we observe is that when the client is connected, all of the messages flow through, but if it disconnects and then reconnects, only the latest of any duplicate of the messages arrive.

Our settings are Qos 1 and retain = true. The conf setting has no allow_duplicate_messages so the default is true.

Is there anything we can do to allow all of the messages to be retained.

Upvotes: 0

Views: 1719

Answers (1)

hardillb
hardillb

Reputation: 59608

You are confusing retained messages for Persistent Sessions.

Only the last message published with the retained bit set will be delivered when the client reconnects normally.

If you want to get ALL messages (regardless of the retained bit being set) sent while the client is off line then you need to use Persistent Sessions.

A detailed description of Persistent Sessions can be found here but the short version is as follows:

You need to connect with the clean_session connection option set to false both times you connect (the initial connection and the reconnect)

Upvotes: 1

Related Questions