Browse Source

Updates #3802

Trying to fix the `not-well-formed` reconnect loop.

- Don't reconnect when we get CONNFAIL error with `not-well-formed`.
- Don't flush immediately after connection when not using BOSH

Not sure about the 2nd change. The `not-well-formed` error happens
because the XML sent is somehow not valid. This reconnect loop happens
sometimes when resuming from suspend. My suspicion is that something
from the previous session is sent which is invalid in the current
session, but I'm not sure what, so this is mostly a stab in the dark.
JC Brand 3 tuần trước cách đây
mục cha
commit
0bb2374482
1 tập tin đã thay đổi với 8 bổ sung1 xóa
  1. 8 1
      src/headless/shared/connection/index.js

+ 8 - 1
src/headless/shared/connection/index.js

@@ -215,7 +215,11 @@ export class Connection extends Strophe.Connection {
         const { api } = _converse;
 
         delete this.reconnecting;
-        this.flush(); // Solves problem of returned PubSub BOSH response not received by browser
+        if (this.isType('bosh')) {
+            // Solves problem of returned PubSub BOSH response not received by browser
+            this.flush();
+        }
+
         await setUserJID(this.jid);
 
         // Save the current JID in persistent storage so that we can attempt to
@@ -338,6 +342,9 @@ export class Connection extends Strophe.Connection {
                 reason === "remote-connection-failed"
             ) {
                 return this.finishDisconnection();
+            } else if (this.disconnection_cause === Strophe.Status.CONNFAIL && this.disconnection_reason  === 'not-well-formed') {
+                // Don't try to automatically reconnect on a not-well-formed error
+                return this.finishDisconnection();
             }
             api.connection.reconnect();
         } else {