# Delay / rate limit drops final message?

**URL:** https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115
**Category:** General
**Created:** [5 March 2021 19:09 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115 "2021-03-05T19:09:56Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![peter\_a](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@peter\_a](https://discourse.nodered.org/u/peter_a)
#### Post date: [5 March 2021 19:09 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/1 "2021-03-05T19:09:57Z")

</div>

I've been using Node Red for the first time over past week, and I'm LOVING it! But I've struck an issue with the Delay node, which I might be misunderstanding...

My flow takes input from a hardware rotary dimmer, calculates some brightness values for a lighting setup, then sends the updated brightness values to a WLED controller. The rotary input generates a huge number of messages per second, and I'm using the delay node to rate limit down to 2 messages a second with "Drop intermediate messages" active, so as not to overload the controller

What I'm finding is that "Drop intermediate messages" will also drop the final message that comes in, if the node is mid-way through delay when that final message arrives. Am I understanding this correctly?

Is there a clean and simple way to ensure that the Delay node always sends the final message it receives? Or, to trigger one more message once the Delay queue is empty?

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [5 March 2021 19:31 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/2 "2021-03-05T19:31:41Z")

</div>

Try a trigger node...

![trigger](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3ca3a8cae2bb8f3a6ab85ea56fb10b845868537a.jpeg)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 March 2021 21:25 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/3 "2021-03-05T21:25:20Z")

</div>

In case you didn't realise, I think Paul intended that you wire the trigger node in parallel with the delay node so that it it passes the last message on after the message stream stops. I think maybe the delay should be 500ms, though it probably doesn't matter.

---

<div class="post-metadata">

### Author: ![peter\_a](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@peter\_a](https://discourse.nodered.org/u/peter_a)
#### Post date: [6 March 2021 16:21 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/4 "2021-03-06T16:21:15Z")

</div>

Brilliant! Exactly what I need. Thanks @Paul-Reed and @Colin for the help.

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [6 March 2021 18:15 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/5 "2021-03-06T18:15:16Z")

</div>

> [@Colin](#):
>
> I think Paul intended that you wire the trigger node in parallel with the delay node so that it it passes the last message on after the message stream stops.

The trigger node will send the last received message 250ms after the last message stream stops.  
No need for a delay node at all, unless I've misread.

The 250ms can be fine tuned so that it avoids repetition, but doesn't cause a noticeable delay.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 March 2021 18:32 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/6 "2021-03-06T18:32:09Z")

</div>

The trigger node _only_ send the last one, the requirement is (I believe) to rate limit but ensure the last one gets through.

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [6 March 2021 18:44 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/7 "2021-03-06T18:44:47Z")

</div>

> [@Colin](#):
>
> the requirement is (I believe) to rate limit but ensure the last one gets through

I read it that OP just wanted the last message, because the rotary dimmer spits out lots of msg's until it arrives at it's final destination, similar to the old problems encountered by the ui\_slider node.  
I'm sure Peter will let us know if it doesn't match his expectations.

---

<div class="post-metadata">

### Author: ![peter\_a](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@peter\_a](https://discourse.nodered.org/u/peter_a)
#### Post date: [6 March 2021 18:51 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/8 "2021-03-06T18:51:23Z")

</div>

I need the crowded stream of messages to be trimmed to around 2 per second, whilst ensuring the very last one isn't discarded. It seems a Delay node + Trigger node in parallel solves the issue. 🙂

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [6 March 2021 21:35 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/9 "2021-03-06T21:35:53Z")

</div>

Ironically it needed @Paul-Reed and myself in series to solve it 🙂

---

<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: [5 May 2021 21:36 UTC](https://discourse.nodered.org/t/delay-rate-limit-drops-final-message/42115/10 "2021-05-05T21:36:33Z")

</div>

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