Closed armandr closed 2 years ago
Update:
So the issues seems to be that if the onStatusChanged closure throws an exception, it will drop the MQTT connection.
Not sure if this is the intended behaviour or the exception should be escalated instead.
I also encountered such a problem, repeatedly disconnected and reconnected inexplicably.
When AWSIotMqttManager.connect(…)
is called, a try/catch block is executed where the connection status callback provided to AWSIotMqttManager.connect(…)
is invoked, followed by calling connect(…)
on the MQTT client. When the code in the try block fails, it goes into a catch block for MqttException
or Exception
. When the connection status callback fails, the catch block for Exception is executed, which sets the connection state to Disconnected. The connection status callback could fail for any number of reasons, since it is defined by the developer, meaning we cannot determine if the error that caused the connection status callback to fail warrants disconnecting the client. To prevent the MQTT client from disconnecting when an error occurs in the connection status callback, you could place your implementation of the connection status callback in a try/catch and handle any potential error based on your implementation.
Closing due to inactivity. Please create a new issue if you have additional questions.
Describe the bug Connecting to a pre-configured mqtt endpoint and policy that currently works fine with aws-ios-sdk.
Upon connection, the connection is then dropped without a reason provided. It is similar to https://github.com/aws-amplify/aws-sdk-android/issues/394 (the device does have the time/date set to automatic)
The set up is similar to the example provided in PubSub example here: https://github.com/awslabs/aws-sdk-android-samples/tree/9c81a6bb6aa3e74a4bba9a02b26681f355260e63/AndroidPubSub
To Reproduce The code is based on the [former] example from:
Which AWS service(s) are affected? AWSIot
Expected behavior Expectation is that the device remains connected to MQTT.
Environment Information (please complete the following information):
Additional context
I'm not sure if this is an Android issue or SDK issue. There is a possibly that Android would be trying to conserve battery and put the thread/app to sleep and lose the TCP/IP connection