瀏覽代碼

Merge pull request #295 from jitsi/5xx_reloads

Page reloads on BOSH HTTP errors
dev1
George Politis 9 年之前
父節點
當前提交
e97ea082d8
共有 2 個檔案被更改,包括 20 行新增7 行删除
  1. 2
    2
      JitsiConnectionEvents.js
  2. 18
    5
      modules/xmpp/xmpp.js

+ 2
- 2
JitsiConnectionEvents.js 查看文件

20
 export const CONNECTION_ESTABLISHED = "connection.connectionEstablished";
20
 export const CONNECTION_ESTABLISHED = "connection.connectionEstablished";
21
 /**
21
 /**
22
  * Indicates that the connection has been failed for some reason. The event
22
  * Indicates that the connection has been failed for some reason. The event
23
- * proivdes the following parameters to its listeners:
23
+ * provides the following parameters to its listeners:
24
  *
24
  *
25
  * @param err {string} the error (message) associated with the failure
25
  * @param err {string} the error (message) associated with the failure
26
  */
26
  */
27
 export const CONNECTION_FAILED = "connection.connectionFailed";
27
 export const CONNECTION_FAILED = "connection.connectionFailed";
28
 /**
28
 /**
29
- * Indicates that the perfomed action cannot be executed because the
29
+ * Indicates that the performed action cannot be executed because the
30
  * connection is not in the correct state(connected, disconnected, etc.)
30
  * connection is not in the correct state(connected, disconnected, etc.)
31
  */
31
  */
32
 export const WRONG_STATE = "connection.wrongState";
32
 export const WRONG_STATE = "connection.wrongState";

+ 18
- 5
modules/xmpp/xmpp.js 查看文件

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;
150
+            const errMsg = msg ? msg : this.lastErrorMsg;
149
             this.disconnectInProgress = false;
151
             this.disconnectInProgress = false;
150
             if (this.anonymousConnectionFailed) {
152
             if (this.anonymousConnectionFailed) {
151
                 // prompt user for username and password
153
                 // prompt user for username and password
152
-                this.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_FAILED,
154
+                this.eventEmitter.emit(
155
+                    JitsiConnectionEvents.CONNECTION_FAILED,
153
                     JitsiConnectionErrors.PASSWORD_REQUIRED);
156
                     JitsiConnectionErrors.PASSWORD_REQUIRED);
154
             } else if(this.connectionFailed) {
157
             } else if(this.connectionFailed) {
155
-                this.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_FAILED,
158
+                this.eventEmitter.emit(
159
+                    JitsiConnectionEvents.CONNECTION_FAILED,
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,
156
                     JitsiConnectionErrors.OTHER_ERROR,
170
                     JitsiConnectionErrors.OTHER_ERROR,
157
-                    msg ? msg : this.lastErrorMsg);
171
+                    errMsg ? errMsg : 'connection-dropped-error');
158
             } else {
172
             } else {
159
                 this.eventEmitter.emit(
173
                 this.eventEmitter.emit(
160
-                        JitsiConnectionEvents.CONNECTION_DISCONNECTED,
161
-                        msg ? msg : this.lastErrorMsg);
174
+                    JitsiConnectionEvents.CONNECTION_DISCONNECTED, errMsg);
162
             }
175
             }
163
         } else if (status === Strophe.Status.AUTHFAIL) {
176
         } else if (status === Strophe.Status.AUTHFAIL) {
164
             // wrong password or username, prompt user
177
             // wrong password or username, prompt user

Loading…
取消
儲存