From 1342431c15444e4fcd0deb61fb3fb0bd618f047d Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:51:08 +0100 Subject: [PATCH] webrtc: fix reconnecting to server after a failure (#4022) --- internal/servers/webrtc/publisher.js | 6 +++--- internal/servers/webrtc/reader.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/servers/webrtc/publisher.js b/internal/servers/webrtc/publisher.js index 6990f4493df..b44babd1005 100644 --- a/internal/servers/webrtc/publisher.js +++ b/internal/servers/webrtc/publisher.js @@ -264,7 +264,7 @@ }); this.pc.onicecandidate = (evt) => this.onLocalCandidate(evt); - this.pc.oniceconnectionstatechange = () => this.onConnectionState(); + this.pc.onconnectionstatechange = () => this.onConnectionState(); this.conf.stream.getTracks().forEach((track) => { this.pc.addTrack(track, this.conf.stream); @@ -372,9 +372,9 @@ return; } - if (this.pc.iceConnectionState === 'failed') { + if (this.pc.connectionState === 'failed') { this.handleError('peer connection closed'); - } else if (this.pc.iceConnectionState === 'connected') { + } else if (this.pc.connectionState === 'connected') { if (this.conf.onConnected !== undefined) { this.conf.onConnected(); } diff --git a/internal/servers/webrtc/reader.js b/internal/servers/webrtc/reader.js index 5385c47d9c2..52a218ef7cb 100644 --- a/internal/servers/webrtc/reader.js +++ b/internal/servers/webrtc/reader.js @@ -371,7 +371,7 @@ this.pc.addTransceiver('audio', { direction }); this.pc.onicecandidate = (evt) => this.onLocalCandidate(evt); - this.pc.oniceconnectionstatechange = () => this.onConnectionState(); + this.pc.onconnectionstatechange = () => this.onConnectionState(); this.pc.ontrack = (evt) => this.onTrack(evt); return this.pc.createOffer() @@ -468,7 +468,7 @@ return; } - if (this.pc.iceConnectionState === 'failed') { + if (this.pc.connectionState === 'failed') { this.handleError('peer connection closed'); } };