From f25f110e0ea2435c8d509e7ea72e905284470e62 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sat, 11 Dec 2021 12:37:02 +0100 Subject: [PATCH] Avoid infinite loop when BOSH URL returns 404 --- src/headless/shared/connection.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/headless/shared/connection.js b/src/headless/shared/connection.js index 9eab4007d..c257e4f40 100644 --- a/src/headless/shared/connection.js +++ b/src/headless/shared/connection.js @@ -228,6 +228,16 @@ export class Connection extends Strophe.Connection { } else { return this.finishDisconnection(); } + } else if (this.status === Strophe.Status.CONNECTING) { + // Don't try to reconnect if we were never connected to begin + // with, otherwise an infinite loop can occur (e.g. when the + // BOSH service URL returns a 404). + const { __ } = _converse; + this.setConnectionStatus( + Strophe.Status.CONNFAIL, + __('An error occurred while connecting to the chat server.') + ); + return this.finishDisconnection(); } else if ( this.disconnection_cause === _converse.LOGOUT || reason === Strophe.ErrorCondition.NO_AUTH_MECH ||