Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] How to use the cleanSession parameter and persistence mechanism for mqtt publisher(publishing messages at QOS 1)


1)  If the cleansession parameter is set to true, this means that in the event of an accidental break of the TCP connection, the QoS 1 messages which were being sent at the time of the break will not be reattempted.  This means that some QoS 1 messages could be lost.

2) The persistence mechanism stores the state if the application shuts down.  When the application restarts, the client library will continue processing the unsent messages.

2.1) This will help in the case of a TCP connection break, but the application does not shut down (or die).

2.2) If cleansession is set to false, yes.

2.3) A callback will be made when the puback is received, or the token will complete.  If no puback is received, then these notifications will not occur.

3) No.  You need to set the cleansession parameter to false.  If it is set to true, then persistence is not needed, as session state is discarded on any TCP connection break.


On 08/15/2016 08:09 PM, Nidhi Kushwaha wrote:

I have recently started learning eclipse Paho(Java client).And I have executed the MqttPublishSample from

I have few doubts regarding the cleanSession parameter and persistence mechanism.

1.If a MQTT client is only publishing messages to topics with QOS 1, does the cleanSession parameter need to set as false ?
Session maintenance is required?If yes why?

2.How persistence mechanism helps in achieving QOS 1 for a MQTT Publisher?

2.1 In what way MemoryPersistence mechanism helps in achieving QOS.

2.2 If MQTT client disconnects(connection lost) during publishing, what will be the role of persistence mechanism w.r.t QOS 1.
For the published messages for which PUBACK message is not received?Paho API will handle the QOS 1 requirement?

2.3 How a MQTT async publisher will know QOS1 is not achieved for particular message.i.e PUBACK message is received.

3.In order to use persistence mechanism do I need to set the cleanSession parameter as true? I want to know if there
is any co-relation between the two? or both are independent feature.

Note:- All the questions I have asked is from the view point of developing a MQTT  Publisher client.


paho-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Ian Craggs                          
icraggs@xxxxxxxxxx                 IBM United Kingdom
Paho Project Lead; Committer on Mosquitto

Back to the top