From 63cca12c9a9fbeca52428e279e2163387e26a596 Mon Sep 17 00:00:00 2001 From: windkh Date: Sun, 8 Sep 2024 18:42:58 +0200 Subject: [PATCH] fixed #170 --- shelly/99-shelly.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shelly/99-shelly.js b/shelly/99-shelly.js index 62c1bc7..dc49fd1 100644 --- a/shelly/99-shelly.js +++ b/shelly/99-shelly.js @@ -1854,7 +1854,7 @@ module.exports = function (RED) { this.hostip = config.hostip; this.server = fastify(); - if (node.port > 0){ + if (node.port > 0 && node.port <= 65535){ node.server.listen({port : node.port}, (err, address) => { if (!err){ console.info("Shelly gen1 server is listening on port " + node.port); @@ -1882,6 +1882,9 @@ module.exports = function (RED) { reply.send(); }); } + else { + node.error("Shelly gen1 server failed to start: port number is not betwee 0 and 65535: " + node.port); + } this.on('close', function (removed, done) { node.server.close().then(() => { @@ -2628,7 +2631,7 @@ module.exports = function (RED) { this.hostip = config.hostip; this.server = fastify(); - if (node.port > 0){ + if (node.port > 0 && node.port <= 65535){ node.server.listen({port : node.port}, (err, address) => { if (!err){ console.info("Shelly gen2 server is listening on port " + node.port); @@ -2659,7 +2662,10 @@ module.exports = function (RED) { reply.send(); }); } - + else { + node.error("Shelly gen1 server failed to start: port number is not betwee 0 and 65535: " + node.port); + } + this.on('close', function (removed, done) { node.server.close().then(() => { done();