Skip to content

Commit

Permalink
Set encodedInsertableStreams also for reconnect response (#921)
Browse files Browse the repository at this point in the history
* Set encodedInsertableStreams also for reconnect response

* Create soft-sheep-occur.md

* move into makeRTCConfig method

* whitespace

* fix comment
  • Loading branch information
lukasIO authored Nov 2, 2023
1 parent 525d90c commit c3e4055
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-sheep-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Fix reconnect when E2EE is enabled
14 changes: 7 additions & 7 deletions src/room/RTCEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,6 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit

const rtcConfig = this.makeRTCConfiguration(joinResponse);

if (this.signalOpts?.e2eeEnabled) {
log.debug('E2EE - setting up transports with insertable streams');
// this makes sure that no data is sent before the transforms are ready
// @ts-ignore
rtcConfig.encodedInsertableStreams = true;
}

const googConstraints = { optional: [{ googDscp: true }] };
this.publisher = new PCTransport(rtcConfig, googConstraints);
this.subscriber = new PCTransport(rtcConfig);
Expand Down Expand Up @@ -529,6 +522,12 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit

private makeRTCConfiguration(serverResponse: JoinResponse | ReconnectResponse): RTCConfiguration {
const rtcConfig = { ...this.rtcConfig };
if (this.signalOpts?.e2eeEnabled) {
log.debug('E2EE - setting up transports with insertable streams');
// this makes sure that no data is sent before the transforms are ready
// @ts-ignore
rtcConfig.encodedInsertableStreams = true;
}

// update ICE servers before creating PeerConnection
if (serverResponse.iceServers && !rtcConfig.iceServers) {
Expand Down Expand Up @@ -1004,6 +1003,7 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
let message = '';
if (e instanceof Error) {
message = e.message;
log.error(e.message);
}
if (e instanceof ConnectionError && e.reason === ConnectionErrorReason.NotAllowed) {
throw new UnexpectedConnectionState('could not reconnect, token might be expired');
Expand Down

0 comments on commit c3e4055

Please sign in to comment.