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.

질문됨 한 달 전147회 조회
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
전문가
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠