Search code examples
androidmqttmessagebrokerpaho

With the clear session flag set to FALSE, I am missing the published values


Is anyone has a logical explanation why despite I have the clear session flage = false I do not receive the updated published message I am subscribed to while i am not connected to the broker?

With the aorementioned flag set to false I ran my App, And i kept publishing to a topic some values (from the PC to the broker not from the Android device to the broker). And then I unpluged the usb of the Android Device frm the pc, and kept publishing some values again. When I plugged the usb to the pc again, i expected to see the values I recently published to that topic, but I did not receive any.

The topic I am publishing to is exactly the topic i am subscribed to, with QoS = 1.


Solution

  • In order for messages to be queued for a client that is no longer connected to a broker, these things must be true:

    • Client must have originally connected with clean session set to false
    • Client must have subscribed with QoS>0
    • Messages to that topic must have been published with QoS>0
    • When the client reconnects it must have the same client id as when it disconnected
    • When the client reconnects it must have clean session set to false

    My bet is that you are failing on either of the latter two points.