HiveMQ

Persistent Session / Queue Message Issue using HiveMQ MQTT CLI Client

Hi There,

I have HiveMQ Enterprise Edition installed in my machine.
I wanted to evaluate the persistence session or clean session feature.

I am using HiveMQ MQTT CLI client to connect and Publisher client and Subscriber client.

In Subscriber Client shell, I ran the following commands:

con -i subclient1 --no-cleanStart -V 5
sub -t test -q 2 -J -s

In Publisher Client shell, I ran the following commands:
con -i pubclient1 --no-cleanStart -V 5
pub -t test -q 2 -r -m ‘test0’
pub -t test -q 2 -r -m ‘test1’

Then in the Subscriber Shell, I was able to see the two messages.
Then disconnected the Subscriber Shell using ctrl C and then dis.

Then in Publisher Client shell, I ran the following commands:
pub -t test -q 2 -r -m ‘test2’
pub -t test -q 2 -r -m ‘test3’

In Subscriber Client shell, I ran the following commands:

con -i subclient1 --no-cleanStart -V 5
sub -t test -q 2 -J -s

I am not seeing the both the new messages “test2” and “test3”. Only seeing the last retained message “test3”. “test2” is lost.

Basically only the last one message is getting displayed at subscriber when it is connected back. All other messages are lost or not getting displayed.

Not sure what I am doing wrong. Can you please let me know.

Is something issue with the HiveMQ MQTT CLI client?

I went through your video in this link: Persistent Session and Queuing Messages - MQTT Essentials: Part 7

Thanks & Regards,
-Venkat

Hi @vgkkonda,

you forgot to add the session expiry to the connect command. The command below says connect and use existing session but the session expiry is 0 (meaning when client disconnects session is also gone):

con -i subclient1 --no-cleanStart -V 5

Fix → add -se (session expiry in seconds) to the connect command:

con -i subclient1 --no-cleanStart -V 5 -se 1000

This means when your client disconnects the broker stores the session for 1.000 seconds and then deletes it (if the client doesn’t reconnect in the meantime).

Greetings,
Michael