Fix reconnection logic to not exhaust retries prematurely#786
Open
TMysliwiec wants to merge 2 commits intolivekit:mainfrom
Open
Fix reconnection logic to not exhaust retries prematurely#786TMysliwiec wants to merge 2 commits intolivekit:mainfrom
TMysliwiec wants to merge 2 commits intolivekit:mainfrom
Conversation
…exhaust a lot of retries prematurely as with the default one - MissedTickBehavior::Burst
This was referenced Nov 16, 2025
ladvoc
approved these changes
Jan 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix for: #481, which was just closed again, likely due to inactivity.
Problem:
The reconnection logic doesn't properly honor the reconnection interval. The interval starts counting from engine creation, not from when reconnection begins. If the engine runs for over 50 seconds (RECONNECT_ATTEMPTS × RECONNECT_INTERVAL), the reconnection loop immediately executes all attempts without waiting, causing it to fail after a couple of seconds. That is because we are using Tokio's default interval, which utilizes MissedTickBehavior::Burst. Any accumulated ticks will fire immediately.
rust-sdks/livekit/src/rtc_engine/mod.rs
Line 52 in 0699735
Solution:
By changing the interval missed tick behavior to MissedTickBehavior::Delay, we can achieve the potentially initially desired await before making another reconnection attempt. That way, the reconnection window is significantly larger, thereby increasing the likelihood of reconnection.
Reproduction steps:
The problem is quite simple to reproduce. You need to run the
basic_roomexample, wait a minute, disconnect the internet, and observe how fast the reconnection attempts are exhausted.