Skip to content

Conversation

@TMysliwiec
Copy link

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.

pub const RECONNECT_ATTEMPTS: u32 = 10;

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_room example, wait a minute, disconnect the internet, and observe how fast the reconnection attempts are exhausted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant