paho.mqtt.android icon indicating copy to clipboard operation
paho.mqtt.android copied to clipboard

Access to sessionPresent after automatic reconnect

Open fabianzwodrei opened this issue 4 years ago • 5 comments

Thanks for this fork and the maintenance.

I am testing a persistent connection between app and broker: I am using the sessionPresent flag after a successul connection to decide if a new subscription is necessary: If server acknowlegdes the connection and set the sessionPresent=true, the app wont need new subscriptions.

But I can't access the sessionPresent flag after a automatic reconnect, because the onSuccess-callback of my IMqttActionListeneris not called. Only the IMqttActionListener onSuccess-callback contains the token for that flag

Am I wrong with my concept of connection and subscription - or might it be useful to implement some sort of access to that sessionPresent flag during the reconnection?

fabianzwodrei avatar Feb 08 '21 11:02 fabianzwodrei

Hmm, is there a call onSuccess() missing ? Anyway, if you found a solution, I'm happy to approve the solution !

hannesa2 avatar Feb 08 '21 11:02 hannesa2

The onSuccess Method of org.eclipse.paho.client.mqttv3 is called in case of a successful reconnect but there is only a MqttReconnectActionListener as a callback called but not the onSuccess of my IMqttActionListener

I debugged this loc: https://github.com/eclipse/paho.mqtt.java/blob/6f35dcb785597a6fd49091efe2dba47513939420/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/ConnectActionListener.java#L87

My workaround at the moment is to disable automatic Reconnect. And to reestablish the connection after 3secs

fabianzwodrei avatar Feb 08 '21 12:02 fabianzwodrei

Note: The first connection made through MqttAndroidClient.connect(...) where I can set the callback to my callback, works perfectly. OnSuccess is called and I can access the sessionPresent comming from the broker server

fabianzwodrei avatar Feb 08 '21 12:02 fabianzwodrei

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

stale[bot] avatar Apr 16 '22 09:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

stale[bot] avatar Jun 04 '23 13:06 stale[bot]