Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Adds a retry logic when fetching conference numbers and pin.

damencho21fb225726dd
diff --git a/react/features/base/util/httpUtils.js b/react/features/base/util/httpUtils.js
index 91c10616e0..3f4eb37aff 100644
--- a/react/features/base/util/httpUtils.js
+++ b/react/features/base/util/httpUtils.js
@@ -1,15 +1,25 @@
+import { timeoutPromise } from './timeoutPromise';
+
const logger = require('jitsi-meet-logger').getLogger(__filename);
+/**
+ * The number of milliseconds before deciding that we need retry a fetch request.
+ *
+ * @type {number}
+ */
+const RETRY_TIMEOUT = 3000;
+
/**
* Wrapper around fetch GET requests to handle json-ifying the response
* and logging errors.
*
* @param {string} url - The URL to perform a GET against.
+ * @param {?boolean} retry - Whether the request will be retried after short timeout.
* @returns {Promise<Object>} The response body, in JSON format, will be
* through the Promise.
*/
-export function doGetJSON(url) {
- return fetch(url)
+export function doGetJSON(url, retry) {
+ const fetchPromise = fetch(url)
.then(response => {
const jsonify = response.json();
@@ -25,4 +35,17 @@ export function doGetJSON(url) {
return Promise.reject(error);
});
+
+ if (retry) {
+ return timeoutPromise(fetchPromise, RETRY_TIMEOUT)
+ .catch(response => {
+ if (response.status >= 400 && response.status < 500) {
+ return Promise.reject(response);
+ }
+
+ return timeoutPromise(fetchPromise, RETRY_TIMEOUT);
+ });
+ }
+
+ return fetchPromise;
}
diff --git a/react/features/invite/components/dial-in-summary/web/DialInSummary.js b/react/features/invite/components/dial-in-summary/web/DialInSummary.js
index 264c5515d2..6feb54df25 100644
--- a/react/features/invite/components/dial-in-summary/web/DialInSummary.js
+++ b/react/features/invite/components/dial-in-summary/web/DialInSummary.js
@@ -177,7 +177,7 @@ class DialInSummary extends Component<Props, State> {
return Promise.resolve();
}
- return doGetJSON(`${dialInConfCodeUrl}?conference=${room}@${mucURL}`)
+ return doGetJSON(`${dialInConfCodeUrl}?conference=${room}@${mucURL}`, true)
.catch(() => Promise.reject(this.props.t('info.genericError')));
}
@@ -204,7 +204,7 @@ class DialInSummary extends Component<Props, State> {
URLSuffix = `?conference=${room}@${mucURL}`;
}
- return doGetJSON(`${dialInNumbersUrl}${URLSuffix}`)
+ return doGetJSON(`${dialInNumbersUrl}${URLSuffix}`, true)
.catch(() => Promise.reject(this.props.t('info.genericError')));
}
diff --git a/react/features/invite/functions.js b/react/features/invite/functions.js
index eaa002bc86..7650afdc15 100644
--- a/react/features/invite/functions.js
+++ b/react/features/invite/functions.js
@@ -48,7 +48,7 @@ export function getDialInConferenceID(
const conferenceIDURL = `${baseUrl}?conference=${roomName}@${mucURL}`;
- return doGetJSON(conferenceIDURL);
+ return doGetJSON(conferenceIDURL, true);
}
/**
@@ -71,7 +71,7 @@ export function getDialInNumbers(
const fullUrl = `${url}?conference=${roomName}@${mucURL}`;
- return doGetJSON(fullUrl);
+ return doGetJSON(fullUrl, true);
}
/**