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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则