Skip to content

Commit

Permalink
Set disconnectedRetryAttempt to be zero and updated getRetryTime
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Jun 22, 2023
1 parent f43cc91 commit 8a26519
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8a26519

Please sign in to comment.