Skip to content

Commit ce4b2de

Browse files
sklikowiczrohandubal
authored andcommitted
[IoT] Check scheduleReconnect() return value in setupCallbackForMqttClient() (#660)
1 parent 0cf2d97 commit ce4b2de

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

aws-android-sdk-iot/src/main/java/com/amazonaws/mobileconnectors/iot/AWSIotMqttManager.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,19 +1338,20 @@ void setupCallbackForMqttClient() {
13381338
public void connectionLost(Throwable cause) {
13391339
LOGGER.warn("connection is Lost");
13401340
if (!userDisconnect && autoReconnect) {
1341-
connectionState = MqttManagerConnectionState.Reconnecting;
1342-
userConnectionCallback();
1343-
13441341
// If we have been connected longer than the connectionStabilityTime then
13451342
// restart the reconnect logic from minimum value before scheduling reconnect.
13461343
if ((lastConnackTime + (connectionStabilityTime * MILLIS_IN_ONE_SECOND)) < getSystemTimeMs()) {
13471344
resetReconnect();
13481345
}
1349-
scheduleReconnect();
1346+
if (scheduleReconnect()) {
1347+
connectionState = MqttManagerConnectionState.Reconnecting;
1348+
} else {
1349+
connectionState = MqttManagerConnectionState.Disconnected;
1350+
}
13501351
} else {
13511352
connectionState = MqttManagerConnectionState.Disconnected;
1352-
userConnectionCallback(cause);
13531353
}
1354+
userConnectionCallback(cause);
13541355
}
13551356

13561357
@Override

0 commit comments

Comments
 (0)