From 9e02bab15590e1b544bf693f26ec7bf189200406 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Mon, 2 Oct 2023 09:50:49 -0400 Subject: [PATCH] Explicitly close the Engine Connection when ICE fails (#732) This will avoid letting the stack think its ready until it times out, and will hopefully help with faster retry logic in the future Signed-off-by: Paul Tagliamonte --- src/lang/std/engineConnection.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lang/std/engineConnection.ts b/src/lang/std/engineConnection.ts index 859d6d5c3..35e1beb23 100644 --- a/src/lang/std/engineConnection.ts +++ b/src/lang/std/engineConnection.ts @@ -360,6 +360,11 @@ export class EngineConnection { if (this.shouldTrace()) { iceSpan.resolve?.() } + } else if (this.pc?.iceConnectionState === 'failed') { + // failed is a terminal state; let's explicitly kill the + // connection to the server at this point. + console.log('failed to negotiate ice connection; restarting') + this.close() } })