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



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.


asked 3 years ago61 views
1 Answer

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.

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions