Prechádzať zdrojové kódy

Avoid infinite loop when BOSH URL returns 404

JC Brand 3 rokov pred
rodič
commit
f25f110e0e
1 zmenil súbory, kde vykonal 10 pridanie a 0 odobranie
  1. 10 0
      src/headless/shared/connection.js

+ 10 - 0
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 ||