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.

質問済み 1ヶ月前146ビュー
1回答
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
エキスパート
回答済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ