UDP Broadcast crash

This is a strange one. I have a large flow, still WIP. It already includes a USP OUT node, which uses msg.port and msg.ip as its parameters. However, when I add another UDP OUT, this time set to broadcast I get an instant crash on deployment or restart:

10 Sep 10:54:01 - [info] [udp out:2e341090cb08ae6c] udp ready: :
10 Sep 10:54:01 - [red] Uncaught Exception:
10 Sep 10:54:01 - Error: setBroadcast EBADF
    at Socket.setBroadcast (dgram.js:783:11)
    at Timeout._onTimeout (/usr/local/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/32-udp.js:184:26)
    at listOnTimeout (internal/timers.js:555:17)
    at processTimers (internal/timers.js:498:7)

The problem still happens when I remove everything except the two UDP nodes, with the resulting JSON export:

[{"id":"dd59ea5e2961a05c","type":"tab","label":"UDP test","disabled":false,"info":"\n\n"},{"id":"f8b16b7dd60256d0","type":"udp out","z":"dd59ea5e2961a05c","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":83.14312744140625,"y":239.90476989746094,"wires":[]},{"id":"a832dc146eb32fd1","type":"udp out","z":"dd59ea5e2961a05c","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"broad","x":86.52397155761719,"y":178.85703945159912,"wires":[]}]

This is the strange part though. If I recreate this simple 2-node flow from scratch, it is ok. Alternatively if I start with the above flow (in safe mode), delete the non-broadcast node and then re-instate it, it also seems to be ok. Also, if I separate the two nodes into different flows, it's also ok. Can anyone shed any light? I'm running v2.0.6 on Ubuntu 20.04LTS.

I just wanted to post a similar post.
Using Raspberry Pi + Node.js 16 I get:
error after a few UDP sending.

After some digging it seems that the problem is with Node.js itself, but it could be eliminated, if socket would be set to null after closing.

I haven't looked into NR's component code, so need to dig into more.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.