# Getting double UDP messages

**URL:** <https://discourse.nodered.org/t/getting-double-udp-messages/66967>\
**Category:** General\
**Created:** [26 August 2022 12:15 UTC](https://discourse.nodered.org/t/getting-double-udp-messages/66967 "2022-08-26T12:15:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shonek](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@shonek](https://discourse.nodered.org/u/shonek)\
**Post date:** [26 August 2022 12:15 UTC](https://discourse.nodered.org/t/getting-double-udp-messages/66967/1 "2022-08-26T12:15:18Z")

</div>

Hello,

I'm trying to integrate a Xiaomi Gateway into my NodeRed, but I'm having a weird issue, and it is that I'm getting all the messages twice. So if I want to toggle a light on motion detected, it will turn on and off at the same second.

Each message should have a unique token, and I receive that token twice in NodeRed. I'm listening to the same Gateway in a node.js script using the "dgram" module, and there I get the messages only once, as it should be, with a unique token per message. Please see the following screenshot for more details:

 ![xiaomi-test_—node_index_js—109×43_y_Node-RED___192_168_68_122_y_aqara_js—_xiaomi-test](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/6902a5023c2a60e6d16d460fc7e160aeeed9489b.jpeg)

I'm new to NodeRed, so I don't know if I'm doing something wrong. I want to move my home automation from node.js to NodeRed for its simplicity.

Thanks.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [26 August 2022 15:30 UTC](https://discourse.nodered.org/t/getting-double-udp-messages/66967/2 "2022-08-26T15:30:51Z")

</div>

Quick question:

Does the problem persist if you restart Node-RED?

---

<div class="post-metadata">

**Author:** ![shonek](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@shonek](https://discourse.nodered.org/u/shonek)\
**Post date:** [29 August 2022 09:15 UTC](https://discourse.nodered.org/t/getting-double-udp-messages/66967/3 "2022-08-29T09:15:17Z")

</div>

Yes, I have restarted it several times. I have NodeRed working on a docker container on a Synology NAS. I have restarted the container, changed the port settings, restarted the whole NAS and lastly updated the NodeRed container to the last version, I had NodeRed 1.1.3 and now I'm using 3.0.2; the problem is the same on both.

I'm thinking about resolving it by just using a variable, everytime a UDP message is sent I will change the variable from 0 to 1 and vice-versa, and I will only let the message continue if the variable is 1. Example:

UDP message received: Var null or 0 -\> stop message -\> Set to 1  
UDP message received: Var 1 -\> continue message -\> Set to 0  
UDP message received: Var 0 -\> stop message -\> Set to 1  
UDP message received: Var 1 -\> continue message -\> Set to 0

It is not the best or fancy solution but I'm a software developer so for me this is much easier than solving a problem related to the network. Anyways I will appreciate if anybody knows how to solve it.

Thanks.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [29 August 2022 10:28 UTC](https://discourse.nodered.org/t/getting-double-udp-messages/66967/4 "2022-08-29T10:28:25Z")

</div>

Follow up questions (now we know it's running in Docker)

- What port forwarding rules do you have enabled for the container
- Where was the standalone nodejs application running? (Inside the same container, on the NAS or on your laptop)
- Do you see the same thing if you run Node-RED not as a container on your NAS?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [29 August 2022 11:03 UTC](https://discourse.nodered.org/t/getting-double-udp-messages/66967/5 "2022-08-29T11:03:26Z")

</div>

will a filter (rbe) node work ? It should filter out duplicates as long as they really are the same.

---

<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:** [18 October 2022 14:53 UTC](https://discourse.nodered.org/t/getting-double-udp-messages/66967/6 "2022-10-18T14:53:44Z")

</div>

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