Every message sent through given broadlink node creates new UDP listener and this listener stays forever.
In result after 64k (max) messages the host system is overloaded with opened UDP ports, NR throws error and restarts itself.
To check the growing number of opened ports use this shell command: "netstat -na |grep udp"
Simple solution: As example here is a modified part of SP2Node.js:
...
this.on('input', function (msg) {
var conf = RED.nodes.getNode(config.device);
var _device;
if (conf != null && conf != undefined && conf != "") {
var _device = new SP2({ address: conf.host, port: 80 }, conf.mac);
}
else {
var device = new SP2({ address: msg.payload.host.trim(), port: 80 }, new Buffer(msg.payload.mac.replace(':', '').replace('-', '').match(/[0-9A-Fa-f]{2}/g).map(function (num) { return parseInt(num, 16); })));
}
// ----------- modification start
// IVO:
setTimeout( function() {
if (typeof (msg.payload) != "object") { msg.payload = {}; }
_device.cs.close();
_device = null;
}, 3000); // 3 seconds waiting for respond !
// ----------- modification end_
_device.auth();
Every message sent through given broadlink node creates new UDP listener and this listener stays forever. In result after 64k (max) messages the host system is overloaded with opened UDP ports, NR throws error and restarts itself. To check the growing number of opened ports use this shell command: "netstat -na |grep udp"
Simple solution: As example here is a modified part of SP2Node.js:
...
this.on('input', function (msg) { var conf = RED.nodes.getNode(config.device); var _device; if (conf != null && conf != undefined && conf != "") { var _device = new SP2({ address: conf.host, port: 80 }, conf.mac); } else { var device = new SP2({ address: msg.payload.host.trim(), port: 80 }, new Buffer(msg.payload.mac.replace(':', '').replace('-', '').match(/[0-9A-Fa-f]{2}/g).map(function (num) { return parseInt(num, 16); }))); } // ----------- modification start // IVO: setTimeout( function() { if (typeof (msg.payload) != "object") { msg.payload = {}; } _device.cs.close(); _device = null; }, 3000); // 3 seconds waiting for respond ! // ----------- modification end_ _device.auth();
Best regards, Ivo