Przeglądaj źródła

feat(xmpp): trigger CONNECTION_FAILED when closed unintentionally

If Strophe drops the connection while not being asked to, it means that
most likely some serious error has occurred. One currently known case is
when a BOSH request fails for more than 4 times then the connection is
dropped without supplying a reason through the Strophe API
(the connection status simply goes to DISCONNECTED).
dev1
paweldomas 9 lat temu
rodzic
commit
2271d2953e
1 zmienionych plików z 12 dodań i 0 usunięć
  1. 12
    0
      modules/xmpp/xmpp.js

+ 12
- 0
modules/xmpp/xmpp.js Wyświetl plik

146
         } else if (status === Strophe.Status.DISCONNECTED) {
146
         } else if (status === Strophe.Status.DISCONNECTED) {
147
             // Stop ping interval
147
             // Stop ping interval
148
             this.connection.ping.stopInterval();
148
             this.connection.ping.stopInterval();
149
+            const wasIntentionalDisconnect = this.disconnectInProgress;
149
             const errMsg = msg ? msg : this.lastErrorMsg;
150
             const errMsg = msg ? msg : this.lastErrorMsg;
150
             this.disconnectInProgress = false;
151
             this.disconnectInProgress = false;
151
             if (this.anonymousConnectionFailed) {
152
             if (this.anonymousConnectionFailed) {
157
                 this.eventEmitter.emit(
158
                 this.eventEmitter.emit(
158
                     JitsiConnectionEvents.CONNECTION_FAILED,
159
                     JitsiConnectionEvents.CONNECTION_FAILED,
159
                     JitsiConnectionErrors.OTHER_ERROR, errMsg);
160
                     JitsiConnectionErrors.OTHER_ERROR, errMsg);
161
+            } else if (!wasIntentionalDisconnect) {
162
+                // XXX if Strophe drops the connection while not being asked to,
163
+                // it means that most likely some serious error has occurred.
164
+                // One currently known case is when a BOSH request fails for
165
+                // more than 4 times. The connection is dropped without
166
+                // supplying a reason(error message/event) through the API.
167
+                logger.error("XMPP connection dropped!");
168
+                this.eventEmitter.emit(
169
+                    JitsiConnectionEvents.CONNECTION_FAILED,
170
+                    JitsiConnectionErrors.OTHER_ERROR,
171
+                    errMsg ? errMsg : 'connection-dropped-error');
160
             } else {
172
             } else {
161
                 this.eventEmitter.emit(
173
                 this.eventEmitter.emit(
162
                     JitsiConnectionEvents.CONNECTION_DISCONNECTED, errMsg);
174
                     JitsiConnectionEvents.CONNECTION_DISCONNECTED, errMsg);

Ładowanie…
Anuluj
Zapisz