浏览代码

Adds a retry logic when fetching conference numbers and pin.

master
damencho 6 年前
父节点
当前提交
21fb225726

+ 25
- 2
react/features/base/util/httpUtils.js 查看文件

1
+import { timeoutPromise } from './timeoutPromise';
2
+
1
 const logger = require('jitsi-meet-logger').getLogger(__filename);
3
 const logger = require('jitsi-meet-logger').getLogger(__filename);
2
 
4
 
5
+/**
6
+ * The number of milliseconds before deciding that we need retry a fetch request.
7
+ *
8
+ * @type {number}
9
+ */
10
+const RETRY_TIMEOUT = 3000;
11
+
3
 /**
12
 /**
4
  * Wrapper around fetch GET requests to handle json-ifying the response
13
  * Wrapper around fetch GET requests to handle json-ifying the response
5
  * and logging errors.
14
  * and logging errors.
6
  *
15
  *
7
  * @param {string} url - The URL to perform a GET against.
16
  * @param {string} url - The URL to perform a GET against.
17
+ * @param {?boolean} retry - Whether the request will be retried after short timeout.
8
  * @returns {Promise<Object>} The response body, in JSON format, will be
18
  * @returns {Promise<Object>} The response body, in JSON format, will be
9
  * through the Promise.
19
  * through the Promise.
10
  */
20
  */
11
-export function doGetJSON(url) {
12
-    return fetch(url)
21
+export function doGetJSON(url, retry) {
22
+    const fetchPromise = fetch(url)
13
         .then(response => {
23
         .then(response => {
14
             const jsonify = response.json();
24
             const jsonify = response.json();
15
 
25
 
25
 
35
 
26
             return Promise.reject(error);
36
             return Promise.reject(error);
27
         });
37
         });
38
+
39
+    if (retry) {
40
+        return timeoutPromise(fetchPromise, RETRY_TIMEOUT)
41
+            .catch(response => {
42
+                if (response.status >= 400 && response.status < 500) {
43
+                    return Promise.reject(response);
44
+                }
45
+
46
+                return timeoutPromise(fetchPromise, RETRY_TIMEOUT);
47
+            });
48
+    }
49
+
50
+    return fetchPromise;
28
 }
51
 }

+ 2
- 2
react/features/invite/components/dial-in-summary/web/DialInSummary.js 查看文件

177
             return Promise.resolve();
177
             return Promise.resolve();
178
         }
178
         }
179
 
179
 
180
-        return doGetJSON(`${dialInConfCodeUrl}?conference=${room}@${mucURL}`)
180
+        return doGetJSON(`${dialInConfCodeUrl}?conference=${room}@${mucURL}`, true)
181
             .catch(() => Promise.reject(this.props.t('info.genericError')));
181
             .catch(() => Promise.reject(this.props.t('info.genericError')));
182
     }
182
     }
183
 
183
 
204
             URLSuffix = `?conference=${room}@${mucURL}`;
204
             URLSuffix = `?conference=${room}@${mucURL}`;
205
         }
205
         }
206
 
206
 
207
-        return doGetJSON(`${dialInNumbersUrl}${URLSuffix}`)
207
+        return doGetJSON(`${dialInNumbersUrl}${URLSuffix}`, true)
208
             .catch(() => Promise.reject(this.props.t('info.genericError')));
208
             .catch(() => Promise.reject(this.props.t('info.genericError')));
209
     }
209
     }
210
 
210
 

+ 2
- 2
react/features/invite/functions.js 查看文件

48
 
48
 
49
     const conferenceIDURL = `${baseUrl}?conference=${roomName}@${mucURL}`;
49
     const conferenceIDURL = `${baseUrl}?conference=${roomName}@${mucURL}`;
50
 
50
 
51
-    return doGetJSON(conferenceIDURL);
51
+    return doGetJSON(conferenceIDURL, true);
52
 }
52
 }
53
 
53
 
54
 /**
54
 /**
71
 
71
 
72
     const fullUrl = `${url}?conference=${roomName}@${mucURL}`;
72
     const fullUrl = `${url}?conference=${roomName}@${mucURL}`;
73
 
73
 
74
-    return doGetJSON(fullUrl);
74
+    return doGetJSON(fullUrl, true);
75
 }
75
 }
76
 
76
 
77
 /**
77
 /**

正在加载...
取消
保存