Persistent Sessions using the MQTT5

0

We are creating the connection using the MQTT5. we are looking for persist the session so when we will reconnect than the session resumes, subscriptions are reinstated, and unacknowledged subscribed messages received and stored prior to the reconnection are sent to the client. For that what will be the flag need to set while connecting and disconnecting. I have used (mqtt5.ClientSessionBehavior.RejoinAlways) while creating the connection and (mqtt5.ClientSessionBehavior.Clean) while reconnecting but it is not working.

Looking for support to achieve the above mentioned scenario.

demandé il y a un mois147 vues
1 réponse
0

When connecting the client, set the cleanSession flag to false to resume an existing session if one exists.

Set the sessionExpiryInterval to a non-zero value to persist the session for a duration even after disconnection.

On reconnecting, subscriptions, pending messages and QoS 1 messages will be reinstated from the previous session.

You can test this by publishing messages while the client is disconnected. On reconnecting, these messages should be received by the client.

Make sure the client ID remains the same across connections for the broker to identify and resume the correct session.

profile picture
EXPERT
répondu il y a un mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions