Skip to content

Commit 0bb2374

Browse files
committed
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.
1 parent c3b2fb7 commit 0bb2374

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/headless/shared/connection/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ export class Connection extends Strophe.Connection {
215215
const { api } = _converse;
216216

217217
delete this.reconnecting;
218-
this.flush(); // Solves problem of returned PubSub BOSH response not received by browser
218+
if (this.isType('bosh')) {
219+
// Solves problem of returned PubSub BOSH response not received by browser
220+
this.flush();
221+
}
222+
219223
await setUserJID(this.jid);
220224

221225
// Save the current JID in persistent storage so that we can attempt to
@@ -338,6 +342,9 @@ export class Connection extends Strophe.Connection {
338342
reason === "remote-connection-failed"
339343
) {
340344
return this.finishDisconnection();
345+
} else if (this.disconnection_cause === Strophe.Status.CONNFAIL && this.disconnection_reason === 'not-well-formed') {
346+
// Don't try to automatically reconnect on a not-well-formed error
347+
return this.finishDisconnection();
341348
}
342349
api.connection.reconnect();
343350
} else {

0 commit comments

Comments
 (0)