rust-sdks icon indicating copy to clipboard operation
rust-sdks copied to clipboard

Reconnection attempts do not honor the reconnection interval

Open TomaszMysliwiec opened this issue 1 year ago • 1 comments

Based on my internal tests the reconnection attempts do not honor the reconnection interval or at least in most cases will not honor it.

This might be related to the fact that reconnecting_interval is spawned after connecting and while in the session it's constantly stacking up events causing multiple instant resolutions inside the reconnect task depending on how much time passed: https://github.com/livekit/rust-sdks/blob/06997356c083b01da766c4c93e8c4e8354d871ce/livekit/src/rtc_engine/mod.rs#L695

It looks like the custom interval doesn't support different MissedTickBehavior: https://github.com/livekit/rust-sdks/blob/06997356c083b01da766c4c93e8c4e8354d871ce/livekit-runtime/src/async_std.rs#L11-L12

so potential solution would be to add inner.reconnecting_interval.lock().await.reset(); before starting the reconnection task: https://github.com/livekit/rust-sdks/blob/06997356c083b01da766c4c93e8c4e8354d871ce/livekit/src/rtc_engine/mod.rs#L599-L600 but that's just an initial, potentially dirty, quick fix.

Please take a look into this issue as it reduces the designed 50-second reconnection window down to 10-15 seconds.

TomaszMysliwiec avatar Nov 05 '24 13:11 TomaszMysliwiec

This is still not fixed. I created a PR with a fix here: https://github.com/livekit/rust-sdks/pull/786

TMysliwiec avatar Nov 15 '25 17:11 TMysliwiec