Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mosquitto-dev] Question about persistent session behavior after broker restart

Hello Mosquitto Developers,

I’ve observed a behavior with persistent sessions in Mosquitto and would like to confirm if this is expected.


Setup:

Mosquitto version 2.0.22 with persistence enabled:

persistence true
persistence_location /path/mosq/data/

MQTT v3.1.1 clients using stable client_ids.

Publisher uses QoS 1.

Subscriber (client2) connects with clean_session=false and then disconnects.


Test sequence:

1. Both publisher and subscriber connect. Subscriber uses clean_session=false.


2. Disconnect client2 and keep it offline.


3. Publish some X messages → they queue for client2.


4. Restart the Mosquitto broker (so it reloads its persistent database).


5. Without reconnecting client2, publish some more Y messages.


6. Reconnect client2.



Result:

On reconnect, client2 receives the X messages (published before the broker restart).

It does not receive the Y messages published after the restart while it was still offline.


Question:

Is this the intended behavior?
After a broker restart, must a client reconnect at least once to re-establish its session before the broker will queue new QoS 1 messages for it?

I had assumed that if a session was persisted and restored, the broker would continue to queue new QoS 1 messages for that client even if it hadn’t reconnected yet — but in my test, that did not happen.

Thanks for clarifying how persistent sessions are expected to behave after a restart.


Regards,
Mohd Uvaish
New Delhi, India
uvaishbharat@xxxxxxxxx 

Back to the top