diff --git a/lib/src/core/engine.dart b/lib/src/core/engine.dart index 7ad52076..6896b440 100644 --- a/lib/src/core/engine.dart +++ b/lib/src/core/engine.dart @@ -159,12 +159,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); @@ -631,6 +631,7 @@ class Engine extends Disposable with EventsEmittable { await events.waitFor( filter: (event) => event.isPrimary && event.state.isConnected(), duration: connectOptions.timeouts.peerConnection, + onTimeout: () => throw MediaConnectException('ice restart failed'), ); logger.fine('resumeConnection: primary connected'); } diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart index e4d8e8ac..46245bbf 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 { diff --git a/lib/src/publication/track_publication.dart b/lib/src/publication/track_publication.dart index f87222bf..549222ba 100644 --- a/lib/src/publication/track_publication.dart +++ b/lib/src/publication/track_publication.dart @@ -131,6 +131,7 @@ abstract class TrackPublication extends Disposable { '${this} Sending mute signal... sid:${sid}, muted:${event.muted}'); participant.room.engine.signalClient.sendMuteTrack(sid, event.muted); } + _metadataMuted = event.muted; // emit events final newEvent = event.muted ? TrackMutedEvent(participant: participant, publication: this)