From 851a9c55fa19b9f828837bda9c6d084963ca6d50 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Fri, 23 Jun 2023 21:43:05 -0400 Subject: [PATCH] Fix for #32 - Add the response check when updating client info --- Client/controllers/clientController.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Client/controllers/clientController.js b/Client/controllers/clientController.js index d88194f..8d02999 100644 --- a/Client/controllers/clientController.js +++ b/Client/controllers/clientController.js @@ -137,6 +137,16 @@ exports.checkIn = async () => { reqOptions = new requestOptions("/nodes/nodeCheckIn", "POST"); sendHttpRequest(reqOptions, JSON.stringify(runningClientConfig), (responseObject) => { log.DEBUG("Check In Respose: ", responseObject); + // Check if the server responded + if (!responseObject) { + log.WARN("Server did not respond to checkIn. Will wait 60 seconds then try again"); + setTimeout(() => { + // Run itself again to see if the server is up now + this.checkIn(); + }, 60000); + return + } + if (responseObject.statusCode === 202) { log.DEBUG("Updated keys: ", responseObject.body.updatedKeys) // Server accepted an update