From 9e7fcdfe152bc5aff28316ccc7edf6441787a46d Mon Sep 17 00:00:00 2001 From: azivner Date: Thu, 16 Nov 2017 20:08:04 -0500 Subject: [PATCH] experimental implementation of sync toggle --- services/sync.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/sync.js b/services/sync.js index cc22a0796..a55ff8ca5 100644 --- a/services/sync.js +++ b/services/sync.js @@ -17,6 +17,7 @@ const SYNC_TIMEOUT = config['Sync']['syncServerTimeout'] || 5000; const SYNC_PROXY = config['Sync']['syncProxy']; let syncInProgress = false; +let proxyToggle = true; async function sync() { if (syncInProgress) { @@ -53,6 +54,8 @@ async function sync() { }; } catch (e) { + proxyToggle = !proxyToggle; + if (e.message.indexOf('ECONNREFUSED') !== -1) { log.info("No connection to sync server."); @@ -225,7 +228,7 @@ async function syncRequest(syncContext, method, uri, body) { timeout: SYNC_TIMEOUT }; - if (SYNC_PROXY) { + if (SYNC_PROXY && proxyToggle) { options.proxy = SYNC_PROXY; }