Persistant Session & Queuing Message, Session Expiry

@Harry ,

Now create a persistent session for a subscriber:

mqtt sub -t Test -se 3600 --no-cleanStart -v -i Subscriber

Go to the localhost:8080 to the HiveMQ Control Center → Clients, Refresh the list, and note that your Subscriber client is connected with “clean start: false”.

Then from another terminal window, do find the subscribers process and terminate it.

To find the process PID:

ps -ef | head -1; ps -ef | grep mqtt | grep -v grep

To terminate the PID:

kill -s TERM <PID>

Go to the HiveMQ Control Center → Clients again, Refresh the list, and see that your Subscriber is still in the list but in the disconnected state.

Now publish a few messages to the Test topic. Note that only messages QoS 1 and 2 will be persisted:

for i in {0..1000}; do mqtt publish --topic Test --message "Hello$i" --identifier Publisher --qos 1 --verbose; sleep 1; done

Go to the HiveMQ Control Center → Clients again, refresh the list, and see if the current queue size is changing for the Subscriber:

Go to the HiveMQ Control Center → Dashboard and check the queue size:
image

When you are tired of publishing, go to the Publisher’s terminal window and terminate it with Ctrl+C. You might need to Ctrl+C more than once.

I hope this helps
Kind regards,
Dasha from HiveMQ team

1 Like