# Reset message limit

**URL:** https://discourse.nodered.org/t/reset-message-limit/27516
**Category:** General
**Created:** [29 May 2020 23:45 UTC](https://discourse.nodered.org/t/reset-message-limit/27516 "2020-05-29T23:45:41Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Joaovitor](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Joaovitor](https://discourse.nodered.org/u/Joaovitor)
#### Post date: [29 May 2020 23:45 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/1 "2020-05-29T23:45:41Z")

</div>

I'm using the delay node in rate limit mode in an application.

Basically the node returns messages from time to time as it includes the function of deleting stored messages.

If the node is set to 1msg / 10 seconds, a single message is sent every ten seconds with the intermediates being excluded. Well, you should already know that.

My question is whether there is a way to reset the time, in a way to stop the count and return to the initial state.

In my application, times vary a lot, arriving on time 2 hours. The problem is that if I make a change when the count has not ended, I have to wait until the count is finished before returning the message.

I tried to send msg.reset to the node, but due to the rate limit mode it didn't work, unlike the delay mod itself. In a way he didn't send any more messages.

---

<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: [30 May 2020 07:46 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/2 "2020-05-30T07:46:16Z")

</div>

Would an RBE node work for you instead or do you also need to rate limit even when the values are different each time?

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [30 May 2020 08:14 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/3 "2020-05-30T08:14:55Z")

</div>

The delay node documentation says:

> flush
> 
> If the received message has this property set to any value, all outstanding messages held by the node are sent immediately.

Would this be what you are after?

Edit: Probably not now after reading your message the second time.

---

<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: [30 May 2020 08:22 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/4 "2020-05-30T08:22:50Z")

</div>

It hard to answer without more details of what exactly your trying to acheive but [https://flows.nodered.org/node/node-red-contrib-queue-gate](https://flows.nodered.org/node/node-red-contrib-queue-gate) gives you a great deal of control over passing/blocking/flushing/queuing messages

---

<div class="post-metadata">

### Author: ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)
#### Post date: [30 May 2020 08:24 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/5 "2020-05-30T08:24:48Z")

</div>

If I set the delay node to rate limit 1msg/10sec (dropping intermediate messages), the first message within 10 seconds gets through immediately. Is the problem with this that you would like the last message to be passed through and not the first when there's more than 1 msg send during the 10 second period?

---

<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: [30 May 2020 12:36 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/6 "2020-05-30T12:36:23Z")

</div>

I think we need a bit more explanation what exactly you are trying to achieve. If you are in rate limit mode and send a msg.reset - it should cancel that timeout and then send the next message to arrive - (which may mean you could then violate your max rate - but we assume you know what you are doing),

---

<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: [30 May 2020 13:35 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/7 "2020-05-30T13:35:23Z")

</div>

> [@dceejay](#):
>
> If you are in rate limit mode and send a msg.reset - it should cancel that timeout and then send the next message to arrive

I think that is exactly what is required, but it doesn't work, for me anyway. The reset seems to do nothing

```auto
[{"id":"5fec537c.2b9434","type":"delay","z":"bdd7be38.d3b55","name":"","pauseType":"rate","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":381,"y":775,"wires":[["91909ddc.e46a8"]]},{"id":"91909ddc.e46a8","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":582,"y":774,"wires":[]},{"id":"51a1b6d.c1b2d48","type":"inject","z":"bdd7be38.d3b55","name":"Two seconds repeat","topic":"","payload":"","payloadType":"date","repeat":"2","crontab":"","once":true,"onceDelay":0.1,"x":136,"y":776,"wires":[["5fec537c.2b9434"]]},{"id":"10305413.2a7d9c","type":"inject","z":"bdd7be38.d3b55","name":"Reset","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":86,"y":843,"wires":[["9b0de79e.6c65d8"]]},{"id":"9b0de79e.6c65d8","type":"change","z":"bdd7be38.d3b55","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":842,"wires":[["5fec537c.2b9434"]]}]

```

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

---

<div class="post-metadata">

### Author: ![Joaovitor](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Joaovitor](https://discourse.nodered.org/u/Joaovitor)
#### Post date: [30 May 2020 13:51 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/8 "2020-05-30T13:51:04Z")

</div>

Well, I managed to solve the problem myself.

Build a flow with delay and other nodes that do what I want very well.

see:  
`[{"id":"ad4787ae.9af8d8","type":"debug","z":"cfbb6e4f.6526a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":4270,"y":1380,"wires":[]},{"id":"c8c089a5.a1c128","type":"inject","z":"cfbb6e4f.6526a","name":"","topic":"reset","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":3460,"y":1380,"wires":[["a5b93380.d665c"]]},{"id":"a5b93380.d665c","type":"change","z":"cfbb6e4f.6526a","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3660,"y":1380,"wires":[["caf34cff.30d29","fb908b7b.8419d8"]]},{"id":"9245f33b.b547f","type":"inject","z":"cfbb6e4f.6526a","name":"","topic":"","payload":"Hello","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":3890,"y":1380,"wires":[["5eb8db40.6613c4"]]},{"id":"eb362fe1.f702b","type":"function","z":"cfbb6e4f.6526a","name":"","func":"msg.topic = \"control\";\nmsg.payload = \"open\"\nreturn msg;","outputs":1,"noerr":0,"x":4190,"y":1480,"wires":[["fb908b7b.8419d8"]]},{"id":"5eb8db40.6613c4","type":"gate","z":"cfbb6e4f.6526a","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":4090,"y":1380,"wires":[["fe69cd2a.5f1d8","ad4787ae.9af8d8","eb362fe1.f702b"]]},{"id":"caf34cff.30d29","type":"function","z":"cfbb6e4f.6526a","name":"","func":"msg.topic = \"control\";\nmsg.payload = \"open\"\nreturn msg;","outputs":1,"noerr":0,"x":3850,"y":1300,"wires":[["5eb8db40.6613c4"]]},{"id":"fe69cd2a.5f1d8","type":"function","z":"cfbb6e4f.6526a","name":"","func":"msg.topic = \"control\"\nmsg.payload = \"close\"\nreturn msg;","outputs":1,"noerr":0,"x":4090,"y":1300,"wires":[["5eb8db40.6613c4"]]},{"id":"fb908b7b.8419d8","type":"delay","z":"cfbb6e4f.6526a","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":3860,"y":1480,"wires":[["5eb8db40.6613c4"]]}]`  
Well, I realized that my goals are as follows:

- Allow the first message to go smoothly.
- After the first pass, block the passage of any message at the specified time, excluding any sent during that period.
- As soon as time is up, let the first message pass. See, without storage, how the rate limit mode allows.
- Press the reset when desired, allowing an immediate message to pass after the reset.

In fact the rate limit problem is when the option to delete intermediate messages is enabled, it is not possible to restart the count.

Well, I don't know what the problem was, but the flow is already doing what I want.

---

<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: [30 May 2020 14:14 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/9 "2020-05-30T14:14:01Z")

</div>

So - ok - that seems like a bug to me- if we don't drop messages then reset does reset the queue AND resets the time... in drop messages mode we don't... thoughts ?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [30 May 2020 14:16 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/10 "2020-05-30T14:16:33Z")

</div>

Agreed. Should reset the time in both cases

---

<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: [30 May 2020 14:18 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/11 "2020-05-30T14:18:30Z")

</div>

Fixed in dev.

---

<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: [29 July 2020 14:18 UTC](https://discourse.nodered.org/t/reset-message-limit/27516/12 "2020-07-29T14:18:38Z")

</div>

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