Wait for a longer time after failed poll and extend default timeout

pull/277/head
beaudan 6 years ago
parent d960739ac2
commit 54bd75e9a6

@ -8,7 +8,7 @@ const endpointBase = '/v1/storage_rpc';
// A small wrapper around node-fetch which deserializes response // A small wrapper around node-fetch which deserializes response
const fetch = async (url, options = {}) => { const fetch = async (url, options = {}) => {
const timeout = options.timeout || 5000; const timeout = options.timeout || 10000;
const method = options.method || 'GET'; const method = options.method || 'GET';
const address = parse(url).hostname; const address = parse(url).hostname;

@ -3,7 +3,8 @@
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
(function() { (function() {
let server; let server;
const POLL_TIME = 100; const SUCCESS_POLL_TIME = 100;
const FAIL_POLL_TIME = 2000;
function stringToArrayBufferBase64(string) { function stringToArrayBufferBase64(string) {
return dcodeIO.ByteBuffer.wrap(string, 'base64').toArrayBuffer(); return dcodeIO.ByteBuffer.wrap(string, 'base64').toArrayBuffer();
@ -89,10 +90,11 @@
} catch (err) { } catch (err) {
connected = false; connected = false;
} }
const pollTime = connected ? SUCCESS_POLL_TIME : FAIL_POLL_TIME;
callback(connected); callback(connected);
setTimeout(() => { setTimeout(() => {
this.pollServer(callback); this.pollServer(callback);
}, POLL_TIME); }, pollTime);
}; };
this.isConnected = function isConnected() { this.isConnected = function isConnected() {

Loading…
Cancel
Save