Skip to content

Commit

Permalink
webrtc: fix reconnecting to server after a failure (#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Jan 6, 2025
1 parent 6d7d0e6 commit 1342431
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/servers/webrtc/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions internal/servers/webrtc/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -468,7 +468,7 @@
return;
}

if (this.pc.iceConnectionState === 'failed') {
if (this.pc.connectionState === 'failed') {
this.handleError('peer connection closed');
}
};
Expand Down

0 comments on commit 1342431

Please sign in to comment.