Fix RTC reconnection and WebSocket connection notification issue#885
Open
CMzhizhe wants to merge 1 commit intolivekit:mainfrom
Open
Fix RTC reconnection and WebSocket connection notification issue#885CMzhizhe wants to merge 1 commit intolivekit:mainfrom
CMzhizhe wants to merge 1 commit intolivekit:mainfrom
Conversation
…nnection, no notification was sent to the upper-layer application.
|
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.
我发现了2处bug,都是关于底层重连的问题
1、当我手机断开了网络,LiveKit会产生如下日志,这bug的情况,不是必现的,有概率会出现
websocket 调用onFailure(),liveKit sdk 会帮助我们恢复重连,从 2026-03-14 18:14:57.492 的时间点就可以看见,此时 connectionState 的值是 RESUMING,onIceConnection 的值会是ConnectionState.DISCONNECTED
2026-03-14 18:15:13.065 connectionState 会收到调用 oldVal.connectionState = RESUMING newVal.connectionState = DISCONNECTED ,livekit 漏了处理oldVal.connectionState = RESUMING的情况
When WebSocket calls
onFailure(), the LiveKit SDK helps us recover and reconnect. This can be seen from the time point 2026-03-14 18:14:57.492, whereconnectionStateisRESUMINGandonIceConnectionisConnectionState.DISCONNECTED.At 2026-03-14 18:15:13.065,
connectionStatewill receive calls tooldVal.connectionState = RESUMINGandnewVal.connectionState = DISCONNECTED. LiveKit missed handling the case whereoldVal.connectionState = RESUMING.2、当我手机断开了网络 websocket 无法连接服务器,会调用到 onFailure() ,但是不会通知上层调用者
在onFailure()方法中,只有当wasConnected为true时,才会调用handleWebSocketClose。但在重新连接场景中,WebSocket在尝试重新连接时失败——此时isConnected已经为false(它是由之前的handleWebSocketClose调用或close()方法设置为false的)。因此,由于wasConnected为false,handleWebSocketClose永远不会被调用,这意味着listener?.onClose(...)也永远不会被调用,上层永远不会得到通知。
In the
onFailure()method,handleWebSocketCloseis only called ifwasConnectedis true. However, in a reconnection scenario, the WebSocket fails when attempting to reconnect—at which pointisConnectedis already false (either because of a previous call tohandleWebSocketCloseor because theclose()method sets it to false). Therefore, sincewasConnectedis false,handleWebSocketClosewill never be called, meaninglistener?.onClose(...)will never be called, and the upper layer will never be notified.