diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index ac847813b..ff1a57029 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -597,13 +597,18 @@ impl Swarm { account: &Account, state: S, ) -> Client { + let mut disconnects = 0; loop { let proxy = self.proxies.choose(&mut thread_rng()).map(|p| p.clone()); match self.add(account, proxy, state.clone()).await { Ok(bot) => return bot, Err(e) => { + disconnects += 1; + let delay = (Duration::from_secs(5) * 2u32.pow(disconnects.min(16))) + .min(Duration::from_secs(15)); let username = account.username.clone(); - error!("Error joining as {username}: {e}. Retrying..."); + error!("Error joining as {username}: {e}. Waiting {delay:?} and trying again."); + tokio::time::sleep(delay).await; } } }