# I'm after (I think anyway) a rate limited gate

**URL:** https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615
**Category:** General
**Created:** [5 November 2023 09:18 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615 "2023-11-05T09:18:36Z")
**Posts on this page:** 15
**Page:** 2

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2023 11:09 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/21 "2023-11-05T11:09:19Z")

</div>

> [@marcus-j-davies](#):
>
> Re-naming the global queue, should reset it

🙂 That lets me carry on testing 🙂

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2023 11:37 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/22 "2023-11-05T11:37:14Z")

</div>

Ok - it seems to do the job

One other thing apart from reset - when manually slowly testing, i.e. sending 3 messages - 1st one goes thru - other 2 are queued

I'm manually injecting into the release node but when I see the queue goto zero, sometimes I forget to press again

And then of course, at the start of my next test - the 1st message is unexpectedly queued

Could you add some visual clue as to the difference between - next msg will go straight thru and next msg will be queued.

Just for us older people who can't remember how many times they've pressed a button 🙂

[edit}I'd suggest green for good to go and maybe keep it at yellow until semaphore reset?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [5 November 2023 11:40 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/23 "2023-11-05T11:40:23Z")

</div>

Agreed!

I’ll add a global stat, to state if release has not been called (either manually or via fs) to let us know if the lock is currently engaged!

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2023 11:41 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/24 "2023-11-05T11:41:16Z")

</div>

I'd suggest green for good to go and maybe keep it at yellow until semaphore reset?

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2023 12:00 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/25 "2023-11-05T12:00:06Z")

</div>

All testing passed so going to fully integrate it into my project 🙂

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [5 November 2023 12:05 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/26 "2023-11-05T12:05:02Z")

</div>

Im working on the enhancements now...

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2023 12:16 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/27 "2023-11-05T12:16:19Z")

</div>

I did try bodging in a reset but it didn't work so glad a proper solution is on the way 🙂

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [5 November 2023 12:22 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/28 "2023-11-05T12:22:07Z")

</div>

The `smp_reset` property will be sent to the release node.  
and if this property is `true`

Will dispose of and clear all awaiting messages across all `take` nodes.

I have chosen the magic prefix of `smp_` so it doesn't affect any other nodes in the flow (well should't do, I cant control what others around the world do in their Nodes 😆 )

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2023 14:00 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/29 "2023-11-05T14:00:26Z")

</div>

Decided to have a pay with setting a fail-safe time

Set it using an inject (cause I have another inject to put it back to 0)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c99f3912d174bb8dd9eab77d34905bea9f37dc27.png)

Semaphore take node shows LFS 5000  
But after 1st message has gone thru - it changes back to disabled - which was unexpected

Why doesn't it keep using the FS time set?

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [5 November 2023 14:11 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/30 "2023-11-05T14:11:19Z")

</div>

The magic property is `smp_failsafeTimeout` 😄 and will be applied once a message with this property passes through, if the next message to pass, does not have this property, it will use whatever is setup in the Node it's self

its like an override for the message currently holding the lock closed

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2023 16:05 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/31 "2023-11-05T16:05:34Z")

</div>

Don't think I'm quite on the same page yet 🙂

So, what I'm after is to inject a failsafe timeout to override the manual timeout setting.

And for this setting to be applied for ALL currently queued and future messages until I change it again

Are you saying that I need to use smp\_failsafeTimeout?

This is all quite confusing 🙂

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [5 November 2023 16:18 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/32 "2023-11-05T16:18:22Z")

</div>

Think of it this way...

The fail-safe is applied per message, and it governs how long a message has, to hit the `release` node.  
So if it doesn't hit the release node by the fail-safe time - the next message will allow to pass.

But if you need to give more time to a message - (example somewhere in your flow it suddenly needs more time for a specific message to finish), you can set a new fail-safe time (with the **FS Reset Node** )

Both **FS Reset** and the **Take** node will use the fail safe default (set in the node its self).

Example you can send 2 messages where one has 10s to complete, and the other has 20s to complete

```auto
node.send({..., `smp_failsafeTimeout`:10000}) /* Will have 10s to complete once its allowed through */
node.send({..., `smp_failsafeTimeout`:20000}) /* Will have 20s to complete once its allowed through */

```

And each of these can be changed (whilst it's in transit to the `Release` node via the `FS Reset` Node)

if you don't specify `smp_failsafeTimeout` it will use what is setup in the Node

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [6 November 2023 09:15 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/33 "2023-11-06T09:15:13Z")

</div>

After a good nights sleep, I realise that most of this is standard stuff.

Manual setting in the node is overridden on a per message basis by msg.smp\_failsafeTimeout

But IMHO the msg.fail-safe action is non-standard and confusing

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [6 November 2023 09:33 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/34 "2023-11-06T09:33:58Z")

</div>

Your right to suggest this.

I'd forgotten that I actually use that technique in other flows i.e.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e7213089b5c983f95f49409a5d0e50c80bccf761.png)

At the moment, I'm going to stick with @marcus-j-davies nodes as they do the same job but with no need for a return wire.\*

And they avoid the delay problem you can get with the 1st message from time to time.

\*But, the NR way is to NOT have invisible wires so I've added this disabled one to keep to the proper spirit 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/4/642965a98cd1f8ba837817d22e1d099381b640f1.png)

or maybe a disabled dummy link would be better?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1fe162a84cf49e5da5ed6537ccbb5c3bb17a9d9f.png)  
with explanation in node name  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/08d4ce5e77de952ba406b773d5e48fc7c4b4073c.png)

I may be over-thinking this now 🙂

---

<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 January 2024 09:34 UTC](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615/35 "2024-01-05T09:34:15Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/im-after-i-think-anyway-a-rate-limited-gate/82615.md?page=1)
