From 8a26519e9836266b1bc19d0630341d8343aa0a8b Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Thu, 22 Jun 2023 19:22:58 +0530 Subject: [PATCH] Set disconnectedRetryAttempt to be zero and updated getRetryTime --- .../main/java/io/ably/lib/transport/ConnectionManager.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/src/main/java/io/ably/lib/transport/ConnectionManager.java b/lib/src/main/java/io/ably/lib/transport/ConnectionManager.java index 3d464d629..bfc3a295c 100644 --- a/lib/src/main/java/io/ably/lib/transport/ConnectionManager.java +++ b/lib/src/main/java/io/ably/lib/transport/ConnectionManager.java @@ -283,7 +283,7 @@ void enact(StateIndication stateIndication, ConnectionStateChange change) { class Disconnected extends State { Disconnected() { super(ConnectionState.disconnected, true, false, false, - ReconnectionStrategy.getRetryTime(ably.options.disconnectedRetryTimeout, disconnectedRetryAttempt), REASON_DISCONNECTED); + ReconnectionStrategy.getRetryTime(ably.options.disconnectedRetryTimeout, ++disconnectedRetryAttempt), REASON_DISCONNECTED); } @Override @@ -302,8 +302,7 @@ StateIndication validateTransition(StateIndication target) { @Override StateIndication onTimeout() { - disconnectedRetryAttempt++; - this.timeout = ReconnectionStrategy.getRetryTime(ably.options.disconnectedRetryTimeout, disconnectedRetryAttempt); + this.timeout = ReconnectionStrategy.getRetryTime(ably.options.disconnectedRetryTimeout, ++disconnectedRetryAttempt); return new StateIndication(ConnectionState.connecting); } @@ -1903,7 +1902,7 @@ private boolean isFatalError(ErrorInfo err) { private CMConnectivityListener connectivityListener; private long connectionStateTtl = Defaults.connectionStateTtl; long maxIdleInterval = Defaults.maxIdleInterval; - private int disconnectedRetryAttempt = 1; + private int disconnectedRetryAttempt = 0; /* for debug/test only */ private final RawProtocolListener protocolListener;