[bug]Early reconnect during the initial room connection
Maintainers usually reply within 1 day
@hiroshihorie is already working on this.
Since Sep 4, 2026.
Assessment
This issue has not been assessed yet.
Description
Describe the bug
During the initial room connection, the initial RTC WebSocket closes while Room.connect is still waiting for the PeerConnection to become connected. The SDK starts an automatic reconnect and opens a second RTC WebSocket approximately 170 ms later, while the original connection attempt is still pending. The original attempt eventually fails after approximately 10 seconds with MediaConnectException.
The two observed RTC WebSocket URLs were:
Initial connection:
wss://<host>/rtc?auto_subscribe=1&adaptive_stream=1&protocol=16&client_protocol=1&sdk=flutter&version=2.11.0&network=wifi&os=android&os_version=16&device_model=PJZ110
Reconnect attempt:
wss://<host>/rtc?auto_subscribe=1&adaptive_stream=1&reconnect=1&reconnect_reason=1&sid=PA_3HVH5rf53iDv&protocol=16&client_protocol=1&sdk=flutter&version=2.11.0&network=wifi&os=android&os_version=16&device_model=PJZ110
To Reproduce
- Use an Android 16 real device on Wi-Fi.
- Use
livekit_client2.11.0 and connect to a room. - Capture WebSocket traffic with Reqable.
- The issue was observed only during a specific period. During that period, approximately 1 in 5 connection attempts reproduced it. It was not reproduced before or after that period, including during other Reqable captures. The issue is not currently reproducible on demand.
- In a failing attempt, observe the initial RTC WebSocket without reconnect parameters, followed by a second RTC WebSocket containing
reconnect=1,reconnect_reason=1, andsidbefore the initial connection finishes. - The initial connection then fails with
MediaConnectExceptionafter approximately 10 seconds.
A minimal research test can force the same ordering by controlling the completion order of the WebSocket and PeerConnection operations. The main reproduction is covered by automatic reconnect starts while the initial Engine.connect still waits for PeerConnection; the trigger and key assertions are at lines 199-207.
Expected behavior
The initial room connection should finish successfully or fail before an automatic reconnect creates another RTC WebSocket. The initial connection and the automatic reconnect should not overlap within the same connection flow.
Platform information
- Flutter version: Flutter 3.38.10 (Dart 3.10.9)
- Plugin version:
livekit_client2.11.0 - Flutter target OS: Android, real device (PJZ110)
- Flutter target OS version: Android 16
- Flutter console log: The connection state reports
disconnectedwith reasonsignal; the original attempt later reportsMediaConnectException: Timed out waiting for PeerConnection to connect, please check your network for ice connectivity.
- Dominant language
- Dart
- Stars
- 421
- Forks
- 260
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 11
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from livekit/client-sdk-flutter
-
`jwtPayload.roomConfiguration` returns null fields for tokens from LiveKit server SDKsPossibly taken @RaphaelFakhri claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
livekit/client-sdk-flutter#1243 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
livekit/client-sdk-flutter#1227 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
livekit/client-sdk-flutter#1221 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
livekit/client-sdk-flutter#1219 · 1 reaction ·
Maintainers usually reply within 1 day
-
iOS: ADM unavailable when a second Flutter engine replaces flutter_webrtc's sharedSingletonPossibly taken @hiroshihorie claimed this 33 days ago. Open
livekit/client-sdk-flutter#1206 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in livekit/client-sdk-flutter
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jhomlala/betterplayer#1609 ·
Maintainers usually reply within 1 day
-
[FR] 缓存键放置在外面Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bggRGjQaUbCoE/PiliPlus#3310 ·
Maintainers usually reply within 1 day
-
package:code_builder type-bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
[material_ui] CalendarDatePicker day numbers are cut off with large text scale on narrow screensOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day