From b1c17a50742842aaedcb1b3692f80e878bd69290 Mon Sep 17 00:00:00 2001 From: Parnic Date: Sat, 25 Jan 2025 12:03:40 -0600 Subject: [PATCH] Catch errors on initial connection --- node_helper.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/node_helper.js b/node_helper.js index 9df2801..1171c24 100644 --- a/node_helper.js +++ b/node_helper.js @@ -389,7 +389,18 @@ module.exports = NodeHelper.create({ cb(poolData); }); - foundUnit.connect(); + foundUnit.connect().catch((ex) => { + Log.error( + `[MMM-IntelliCenter] error attempting to connect to unit: ${ex}`, + ); + Log.error( + `[MMM-IntelliCenter] restarting the connection process in ${reconnectDelayMs / 1000} seconds`, + ); + + unitReconnectTimer = setTimeout(() => { + this.connect(cb, reconnectCb); + }, reconnectDelayMs); + }); }, findServer(cb, reconnectCb) {