Skip to content

Commit

Permalink
Remove initial reconnect delay for resumes
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment committed Apr 27, 2020
1 parent b38ff20 commit 17ac665
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -561,13 +561,15 @@ public void reconnect(boolean callFromQueue) throws InterruptedException
String message = "";
if (callFromQueue)
message = String.format("Queue is attempting to reconnect a shard...%s ", shardInfo != null ? " Shard: " + shardInfo.getShardString() : "");
if (sessionId != null)
reconnectTimeoutS = 0;
LOG.debug("{}Attempting to reconnect in {}s", message, reconnectTimeoutS);
while (shouldReconnect)
{
api.setStatus(JDA.Status.WAITING_TO_RECONNECT);
int delay = reconnectTimeoutS;
// Exponential backoff, reset on session creation (ready/resume)
reconnectTimeoutS = Math.min(reconnectTimeoutS << 1, api.getMaxReconnectDelay());
reconnectTimeoutS = reconnectTimeoutS == 0 ? 2 : Math.min(reconnectTimeoutS << 1, api.getMaxReconnectDelay());
Thread.sleep(delay * 1000);
handleIdentifyRateLimit = false;
api.setStatus(JDA.Status.ATTEMPTING_TO_RECONNECT);
Expand Down

0 comments on commit 17ac665

Please sign in to comment.