Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MQTT Clean session

Tags:

mqtt

Assume that I connected to the broker with "clean session=false" and started receiving events, in case of disconnection ideally my application will still receive data on connection. But if the application is crashed I want to have a fresh start and clear my session.

Can I clear my session on the MQTT broker and have a fresh start?

From the documentation I concluded that if I wanted to do that I would need to do the following:

  1. application start

  2. connect using "clean session=true" // this will cause any current session to be removed along with its data

  3. every thing related to the session is purged from server

  4. disconnect

  5. connect using "clean session=false" and start getting the data.

I got the idea from http://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection-establishment

"If clean session is set to true, the broker won’t store anything for the client and will also purge all information from a previous persistent session."

Is this the correct way to clear a previous session?

like image 937
A.Alqadomi Avatar asked Mar 16 '16 11:03

A.Alqadomi


Video Answer


1 Answers

Yes, that is the only way to clear a session for a client.

like image 57
ralight Avatar answered Sep 16 '22 14:09

ralight