mirror of
https://github.com/screego/server.git
synced 2026-08-30 17:33:30 +08:00
fix: don't close peer connection on transient 'disconnected' state
Both connectionstatechange handlers treated 'disconnected' the same as 'closed' and 'failed' and immediately called peer.close(). Per the WebRTC spec, 'disconnected' only means that ICE connectivity checks are currently failing. The connection frequently recovers on its own -- brief network hiccups, Wi-Fi roaming between access points, or NAT rebinding all trigger it. Calling close() makes that recovery impossible, because a closed RTCPeerConnection cannot be reopened. The result was that a short network glitch permanently killed the stream and the viewer had to reload the page. Leaving 'disconnected' unhandled lets the browser's own ICE recovery do its job. Refs #53
This commit is contained in:
+2
-10
@@ -62,11 +62,7 @@ const hostSession = async ({
|
||||
|
||||
peer.onconnectionstatechange = (event) => {
|
||||
console.log('host change', event);
|
||||
if (
|
||||
peer.connectionState === 'closed' ||
|
||||
peer.connectionState === 'disconnected' ||
|
||||
peer.connectionState === 'failed'
|
||||
) {
|
||||
if (peer.connectionState === 'closed' || peer.connectionState === 'failed') {
|
||||
peer.close();
|
||||
done();
|
||||
}
|
||||
@@ -134,11 +130,7 @@ const clientSession = async ({
|
||||
};
|
||||
peer.onconnectionstatechange = (event) => {
|
||||
console.log('client change', event);
|
||||
if (
|
||||
peer.connectionState === 'closed' ||
|
||||
peer.connectionState === 'disconnected' ||
|
||||
peer.connectionState === 'failed'
|
||||
) {
|
||||
if (peer.connectionState === 'closed' || peer.connectionState === 'failed') {
|
||||
peer.close();
|
||||
done();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user