livekit/client-sdk-swift

Reconnecting State not activated while quick reconnects

buttjer opened this issue · 2 comments

Describe the bug
The room event roomIsReconnecting seems to be called late. The system is already trying to reconnect while the there is no network at all. Also the state remains .connected.

But the event is called if the network is reestablished. Followed immedetiary by roomDidReconnect .
Is this on purpose? I think it should reflect the actual state. The room connect state seems also remain in .connected. I would expect reconnecting or at least disconnected .

Otherwise, how to show the user that the systems is actively trying to reconnect?
No internet could also mean that the system gave up trying to reconnect at all. I can’t see a way to distinguish that.
I also think in the version 1 of the SDK this also behaved differently.

SDK Version
2.0.5

iOS/macOS Version
iOS 17.4.1

Steps to Reproduce
Disable network while in a call.

Expected behavior
Connection State changes to reconnecting.
roomIsReconnecting called.

Logs

2024-04-22T15:05:40+0200 error LiveKitSDK : [LiveKit] Engine.transport(_:didUpdateState:) Failed calling startReconnect, error: Error Domain=io.livekit.swift-sdk Code=104 "Invalid state" UserInfo={NSLocalizedDescription=Invalid state}
2024-04-22T15:05:49+0200 warning LiveKitSDK : [LiveKit] Engine.startReconnect(reason:nextReconnectMode:) [Connect] Reconnect already in progress...
2024-04-22T15:05:49+0200 error LiveKitSDK : [LiveKit] Engine.transport(_:didUpdateState:) Failed calling startReconnect, error: Error Domain=io.livekit.swift-sdk Code=104 "Invalid state" UserInfo={NSLocalizedDescription=Invalid state}
Task <B4FFE66E-82E2-4D5B-9767-7C60D4CD1DA1>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=wss://...&protocol=12&sdk=swift&version=2.0.5&os=iOS&os_version=17.4.1&device_model=iPhone16,1&network=wifi&reconnect=1&auto_subscribe=0&adaptive_stream=0, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalWebSocketTask <B4FFE66E-82E2-4D5B-9767-7C60D4CD1DA1>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <B4FFE66E-82E2-4D5B-9767-7C60D4CD1DA1>.<1>, NSLocalizedDescription=The request timed out.}
2024-04-22T15:05:49+0200 error LiveKitSDK : [LiveKit] WebSocket.urlSession(_:task:didCompleteWithError:) didCompleteWithError: Optional(Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=wss://...&protocol=12&sdk=swift&version=2.0.5&os=iOS&os_version=17.4.1&device_model=iPhone16,1&network=wifi&reconnect=1&auto_subscribe=0&adaptive_stream=0, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalWebSocketTask <B4FFE66E-82E2-4D5B-9767-7C60D4CD1DA1>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <B4FFE66E-82E2-4D5B-9767-7C60D4CD1DA1>.<1>, NSLocalizedDescription=The request timed out.})
2024-04-22T15:05:49+0200 error LiveKitSDK : [LiveKit] Engine.startReconnect(reason:nextReconnectMode:) [Connect] Reconnect mode: .quick failed with error: Error Domain=io.livekit.swift-sdk Code=0 "Unknown" UserInfo={NSLocalizedDescription=Unknown}
2024-04-22T15:05:49+0200 warning LiveKitSDK : [LiveKit] Engine.startReconnect(reason:nextReconnectMode:) [Connect] Reconnect already in progress...
[Retry] Waiting for 1.0 seconds...
2024-04-22T15:05:49+0200 error LiveKitSDK : [LiveKit] Engine.signalClient(_:didUpdateConnectionState:oldState:disconnectError:) Failed calling startReconnect, error: Error Domain=io.livekit.swift-sdk Code=104 "Invalid state" UserInfo={NSLocalizedDescription=Invalid state}
2024-04-22T15:05:50+0200 warning LiveKitSDK : [LiveKit] Engine.startReconnect(reason:nextReconnectMode:) [Connect] Reconnect already in progress...
2024-04-22T15:05:50+0200 error LiveKitSDK : [LiveKit] Engine.transport(_:didUpdateState:) Failed calling startReconnect, error: Error Domain=io.livekit.swift-sdk Code=104 "Invalid state" UserInfo={NSLocalizedDescription=Invalid state}
[Retry] Attempt 2 of 300, delay: 1.0```

This is intentional for v2.
Will discuss with Dev team whether to expose .quick reconnects.

这是 v2 的故意设计。 将与开发团队讨论是否公开 .quick 重新连接。

This resulted in an immediate failure every time a reconnection was initiated