[FIX] web_editor: set recovery connection to 3s

When trying to recover peer to peer connection, the timeout of 500ms or
1000ms might be too short and 15000ms in unnecessary too long.

If the timeout is too short, it could remove the connection before the
peer to peer had the time to reconnect to it. When we call
`_recoverConnection` on `disconnect` in `oniceconnectionstatechange`
or `onconnectionstatechange`, the signal `disconnect` does not
necessarily mean that it will remain disconnected. Doing nothing could
be enough to reconnect.
(see: https://w3c.github.io/webrtc-pc/#dom-rtcicetransportstate-disconnected)

closes odoo/odoo#112182

X-original-commit: 3647374c63fcd4bccf501e49a2af6a707fedd737
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2023-02-08 13:28:13 +01:00
parent fb7f8732a4
commit 6e82d8ee08
@@ -426,7 +426,7 @@ export class PeerToPeer {
break;
case 'disconnected':
await this._recoverConnection(clientId, {
delay: 1000,
delay: 3000,
reason: 'ice connection disconnected',
});
break;
@@ -446,7 +446,7 @@ export class PeerToPeer {
break;
case 'disconnected':
await this._recoverConnection(clientId, {
delay: 500,
delay: 3000,
reason: 'connection disconnected',
});
break;
@@ -468,7 +468,7 @@ export class PeerToPeer {
console.trace(error);
console.groupEnd();
}
this._recoverConnection(clientId, { delay: 15000, reason: 'ice candidate error' });
this._recoverConnection(clientId, { delay: 3000, reason: 'ice candidate error' });
};
const dataChannel = pc.createDataChannel('notifications', { negotiated: true, id: 1 });
let message = [];