Reset message limit

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.

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

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.

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 gives you a great deal of control over passing/blocking/flushing/queuing messages

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?

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),

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

[{"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

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.

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 ?

Agreed. Should reset the time in both cases

Fixed in dev.

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