Skip to main content

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

Hi Mohd,

did you specify Qos = 1 in the subscribing client?

did you specify clean_session false on the second connect of the subscriber?

If you do so, messages published before and after the restart of mosquitto are delivered:


```
$ mosquitto_sub -t persist -i sub -c -q 1
^C

$ mosquitto_pub -t 'persist' -i pub -q 1 -m one
$ mosquitto_pub -t 'persist' -i pub -q 1 -m two
$ mosquitto_pub -t 'persist' -i pub -q 1 -m three

*** restart mosquitto *** 

$ mosquitto_pub -t 'persist' -i pub -q 1 -m four
$ mosquitto_pub -t 'persist' -i pub -q 1 -m five
$ mosquitto_pub -t 'persist' -i pub -q 1 -m six

$ mosquitto_sub -t persist -i sub -c -q 1
one
two
three
four
five
six
```

If your situation is different, show us the mosquitto.log file.

Cheers
   Christoph


Am 08.10.2025 um 01:22 schrieb uvaish siddiqui via mosquitto-dev <mosquitto-dev@xxxxxxxxxxx>:

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
_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/mosquitto-dev


Back to the top