AWS IoT reconnect results in re-subscription of an unsubscribed topic

0

Hi,

I am writing an android app using Java which connects to AWS IoT mqtt using the aws-android-sdk-iot.

After making an initial connection to the broker, I do the following steps -

  1. Subscribe to topic A.
  2. Unsubscribe from topic A.
  3. Subscribe to topic B.
  4. Unsubscribe from topic B.

Now, to simulate an abnormal disconnect, I turn the phone off.

Since I am listening to the LifeCycle events, I see that the connection is disconnected after the keepalive limit expires.
On turning the phone on, reconnect is tried. Successful reconnection happens but I also see a successful subscription to the topic A.

I have unsubscribed from topic A already, so why do I see a re-subscription to that on reconnect?

I have tried setting needResubscribe() to false using setAutoResubscribe(false) on the ASWIotMqttManager but it did not make a difference.

Please let me if this is expected behavior or something going wrong here.

Thanks!

已提問 5 年前檢視次數 331 次
1 個回答
0

Sorry, it was a code mistake. There was a bug in my handling of the connectionStatus = connected where I was trying to subscribe to the group.

已回答 5 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南