From 7934034d364f2da91e9777bc9c025205d07b2125 Mon Sep 17 00:00:00 2001 From: Valentina Schiavi Date: Tue, 9 Jan 2024 11:01:27 +0100 Subject: [PATCH] If the list of devices is empty, wait a certain amount of time before asking again. Fixes #190 --- server/service/IndividualServicesService.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/service/IndividualServicesService.js b/server/service/IndividualServicesService.js index 6b4a549..c2973fb 100644 --- a/server/service/IndividualServicesService.js +++ b/server/service/IndividualServicesService.js @@ -352,6 +352,16 @@ function areEqualArray(listJsonES, listJsonMD) { return true; } +function waitAsync(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +async function executeAfterWait() { + // Wait 60 seconds + await waitAsync(60000); +} + + exports.updateCurrentConnectedEquipment = async function (user, originator, xCorrelator, traceIndicator, customerJourney) { let result; let listDisconnectedEq = []; @@ -382,7 +392,8 @@ exports.updateCurrentConnectedEquipment = async function (user, originator, xCor newConnectedListFromMwdi = await EmbeddingCausesRequestForListOfDevicesAtMwdi(user, originator, xCorrelator, traceIndicator, customerJourney); } catch (error) { - console.error('No Equipment connected. Retry to read...'); + console.error('No Equipment connected. Wait 60 seconds and retry to read...'); + executeAfterWait(); newConnectedListFromMwdi = null; }