# UDP Broadcast crash

**URL:** <https://discourse.nodered.org/t/udp-broadcast-crash/50851>\
**Category:** General\
**Created:** [10 September 2021 10:08 UTC](https://discourse.nodered.org/t/udp-broadcast-crash/50851 "2021-09-10T10:08:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisofCCL](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chrisofccl/32/42442_2.png) [@chrisofCCL](https://discourse.nodered.org/u/chrisofCCL)\
**Post date:** [10 September 2021 10:08 UTC](https://discourse.nodered.org/t/udp-broadcast-crash/50851/1 "2021-09-10T10:08:07Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [17 October 2021 22:14 UTC](https://discourse.nodered.org/t/udp-broadcast-crash/50851/2 "2021-10-17T22:14:26Z")

</div>

I just wanted to post a similar post.  
Using Raspberry Pi + Node.js 16 I get:  
ERR\_SOCKET\_DGRAM\_NOT\_RUNNING  
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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 December 2021 22:14 UTC](https://discourse.nodered.org/t/udp-broadcast-crash/50851/3 "2021-12-16T22:14:36Z")

</div>

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