client-sdk-swift
client-sdk-swift copied to clipboard
Reconnect PrimaryTransportConnected Timeout
Describe the bug When I perform reconnection tests, I find that the WebSocket can quickly establish a connection. However, when executing primaryTransportConnectedCompleter.wait(timeout: _state.connectOptions.primaryTransportConnectTimeout), regardless of whether I set it to 10 seconds, 30 seconds, or 60 seconds, it always times out and fails in the end.
SDK Version 2.0.12
iOS/macOS Version iOS16.7.8
Logs 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] Room.startReconnect(reason:nextReconnectMode:) [Connect] Retry in 6.0 seconds, 3/3 tries left. 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] Room.startReconnect(reason:nextReconnectMode:) [Connect] totalAttempts 3, self.state.nextReconnectMode nil 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] Room.init(delegate:connectOptions:roomOptions:) connectionState: .reconnecting -> .reconnecting, reconnectMode: Optional(.full) 2024-07-16T13:26:22+0800 error LiveKitSDK : [LiveKit] Room.fullReconnectSequence() [Connect] starting .full reconnect sequence... 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<Sid>.reset() 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.reset() 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.reset() 2024-07-16T13:26:22+0800 error LiveKitSDK : [LiveKit] SignalClient.cleanUp(withError:) cleanUp withError: nil 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<ConnectResponse>.reset() 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.reset() 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.reset() 2024-07-16T13:26:22+0800 error LiveKitSDK : [LiveKit] Room.fullConnectSequence(::) fullConnectSequence 2024-07-16T13:26:22+0800 error LiveKitSDK : [LiveKit] SignalClient.cleanUp(withError:) cleanUp withError: nil 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<ConnectResponse>.reset() 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connect(::connectOptions:reconnectMode:adaptiveStream:) [Connect] mode: .full 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connect(::connectOptions:reconnectMode:adaptiveStream:) [Connect] with url: ws://test:36001/rtc?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjExMDgxNjQsImlzcyI6IkFQSWJ4RFdldHFjakhhYSIsIm1ldGFkYXRhIjoie1wicm9vbU5hbWVcIjpcInZqc3BydGNfcm9vbV8zRDI0MjVFRC02NzBBLTRENjYtODI5RC0yNzZGQTNFMzFGMURcIixcInBvcnRyYWl0XCI6XCJcIn0iLCJuYW1lIjoi5YiY5rSLMTUwIiwibmJmIjoxNzIxMTA3NTY0LCJzdWIiOiJhZmU4MDU5ZGJlYmI0ZTM3OTk5MDEwMzZkODcyNTA5Y0BhcHAiLCJ2aWRlbyI6eyJyb29tIjoidmpzcHJ0Y19yb29tXzNEMjQyNUVELTY3MEEtNEQ2Ni04MjlELTI3NkZBM0UzMUYxRCIsInJvb21Kb2luIjp0cnVlfX0.m5I2qWA0usc9qX7OUyMIDwwvHYz6e58qjAW2cLE5Wzg&protocol=12&sdk=swift&version=2.0.12&os=iOS&os_version=16.7.8&device_model=iPhone10,3&network=cellular&reconnect=0&auto_subscribe=1&adaptive_stream=0 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connectionState .disconnected -> .reconnecting 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connect(::connectOptions:reconnectMode:adaptiveStream:) Did enter WebSocket message loop... 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<ConnectResponse>.wait(timeout:) continuation UnsafeContinuation<ConnectResponse, Error>(context: (Opaque Value)) 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connect(::connectOptions:reconnectMode:adaptiveStream:) socket message loop...<LiveKit.WebSocket: 0x280149680> 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<ConnectResponse>.wait(timeout:) Join response waiting milliseconds(7000) with id: 46969137-C426-4D15-8F5B-9502987FCCF7 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connect(::connectOptions:reconnectMode:adaptiveStream:) for try await message in socket messagedata(1140 bytes) 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connect(::connectOptions:reconnectMode:adaptiveStream:) for try await message in socket messagedata(40 bytes) 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<ConnectResponse>.resume(returning:) resume Join response 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<ConnectResponse>.resume(with:) resume entry WaitEntry(continuation: Swift.UnsafeContinuation<LiveKit.SignalClient.ConnectResponse, Swift.Error>(context: (Opaque Value)), timeoutBlock: Dispatch.DispatchWorkItem) 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connectionState .reconnecting -> .connected 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] SignalClient.connect(:_:connectOptions:reconnectMode:adaptiveStream:) Successfully connected 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] Room.configureTransports(connectResponse:) Configuring transports with JOIN response... 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] Room.configureTransports(connectResponse:) subscriberPrimary: true 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.wait(timeout:) continuation UnsafeContinuation<(), Error>(context: (Opaque Value)) 2024-07-16T13:26:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.wait(timeout:) Primary transport connect waiting milliseconds(60000) with id: B7987401-A7B0-43C9-A326-8B87F461D537 2024-07-16T13:27:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.wait(timeout:) Wait B7987401-A7B0-43C9-A326-8B87F461D537 timedOut 2024-07-16T13:27:22+0800 warning LiveKitSDK : [LiveKit] AsyncCompleter<()>.wait(timeout:) timeout 2024-07-16T13:27:22+0800 error LiveKitSDK : [LiveKit] Room.startReconnect(reason:nextReconnectMode:) [Connect] Reconnect mode: .full failed with error: Error Domain=io.livekit.swift-sdk Code=101 "Timed out" UserInfo={NSLocalizedDescription=Timed out} 2024-07-16T13:27:22+0800 error LiveKitSDK : [LiveKit] Room.startReconnect(reason:nextReconnectMode:) [Connect] Sequence failed with error: Error Domain=io.livekit.swift-sdk Code=101 "Timed out" UserInfo={NSLocalizedDescription=Timed out}