diff --git a/lib/src/core/engine.dart b/lib/src/core/engine.dart index 211d724ff..c2e5ce606 100644 --- a/lib/src/core/engine.dart +++ b/lib/src/core/engine.dart @@ -161,12 +161,12 @@ class Engine extends Disposable with EventsEmittable { logger.fine('Waiting for engine to connect...'); - // wait until engine is connected + // wait until primary pc is connected await events.waitFor( filter: (event) => event.isPrimary && event.state.isConnected(), duration: this.connectOptions.timeouts.connection, - onTimeout: () => throw ConnectException( - 'Timed out waiting for EnginePeerStateUpdatedEvent'), + onTimeout: () => throw MediaConnectException( + 'Timed out waiting for PeerConnection to connect, please check your network for ice connectivity'), ); _updateConnectionState(ConnectionState.connected); @@ -646,7 +646,7 @@ class Engine extends Disposable with EventsEmittable { await events.waitFor( filter: (event) => event.isPrimary && event.state.isConnected(), duration: connectOptions.timeouts.iceRestart, - onTimeout: () => throw ConnectException(), + onTimeout: () => throw MediaConnectException('ice restart failed'), ); } } diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart index e4d8e8ac9..46245bbf3 100644 --- a/lib/src/exceptions.dart +++ b/lib/src/exceptions.dart @@ -30,6 +30,15 @@ class ConnectException extends LiveKitException { ConnectException([String msg = 'Failed to connect to server']) : super._(msg); } +/// An exception occured while attempting to disconnect. +/// Common reasons: +/// - Network condition is not good. +/// - SFU deploy behind a NAT and not configured correctly. +/// - Need a turn relay server but not configured. +class MediaConnectException extends LiveKitException { + MediaConnectException([String msg = 'Ice connection failed']) : super._(msg); +} + /// An internal state of the SDK is not correct and can not continue to execute. /// This should not occur frequently. class UnexpectedStateException extends LiveKitException {