# Aynchronous wait node?

**URL:** <https://discourse.nodered.org/t/aynchronous-wait-node/70825>\
**Category:** General\
**Created:** [18 November 2022 10:54 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825 "2022-11-18T10:54:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [18 November 2022 10:54 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/1 "2022-11-18T10:54:45Z")

</div>

Hi,

is there any kind of "asynchronous wait node" that can be used to forward messages with a fixed delay ?  
On the input side many messages are sent in a short period of time (like 10 / sec), but they should be forwarded in fixed time slots (like 1 every 5 sec).

Is that possible or available as node ?

BR  
G

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [18 November 2022 11:11 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/2 "2022-11-18T11:11:27Z")

</div>

You can use the delay node, set it to rate limit and configure your requirements.

 ![SCR-20221118-gx8](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/731f23880bf98a3c162b80226799626eebe3d9eb.png)

---

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [18 November 2022 13:07 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/3 "2022-11-18T13:07:31Z")

</div>

Unfortunately this does not work as intended:

Try this node please and tell me why only one message is forwarded instead of 2 if you click the inject node several times:

> [  
> {  
> "id": "e5cb8c634d4bec13",  
> "type": "inject",  
> "z": "afd9ce7fa0e6c13b",  
> "name": "",  
> "props": [  
> {  
> "p": "payload"  
> },  
> {  
> "p": "topic",  
> "vt": "str"  
> }  
> ],  
> "repeat": "",  
> "crontab": "",  
> "once": false,  
> "onceDelay": 0.1,  
> "topic": "",  
> "payload": "",  
> "payloadType": "date",  
> "x": 220,  
> "y": 600,  
> "wires": [  
> [  
> "f67cd5620450fd1d"  
> ]  
> ]  
> },  
> {  
> "id": "f67cd5620450fd1d",  
> "type": "delay",  
> "z": "afd9ce7fa0e6c13b",  
> "name": "",  
> "pauseType": "rate",  
> "timeout": "5",  
> "timeoutUnits": "seconds",  
> "rate": "2",  
> "nbRateUnits": "2",  
> "rateUnits": "minute",  
> "randomFirst": "1",  
> "randomLast": "5",  
> "randomUnits": "seconds",  
> "drop": true,  
> "allowrate": false,  
> "outputs": 1,  
> "x": 500,  
> "y": 600,  
> "wires": [  
> [  
> "de460a41781c08af"  
> ]  
> ]  
> },  
> {  
> "id": "de460a41781c08af",  
> "type": "debug",  
> "z": "afd9ce7fa0e6c13b",  
> "name": "debug 5",  
> "active": true,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "true",  
> "targetType": "full",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 760,  
> "y": 600,  
> "wires":   
> }  
> ]

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [18 November 2022 13:14 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/4 "2022-11-18T13:14:44Z")

</div>

> [@Gawan](#):
>
> On the input side many messages are sent in a short period of time (like 10 / sec), but they should be forwarded in fixed time slots (like 1 every 5 sec).

Because this is what you said you wanted.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 November 2022 13:30 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/5 "2022-11-18T13:30:04Z")

</div>

You need to set it to queue intermediate messages, not drop them

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 November 2022 13:33 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/6 "2022-11-18T13:33:10Z")

</div>

You have to click the `</>` button before pasting your code. That protects the code from the forum software which will otherwise mangle it.

Your delay node is set to rate limit: 2 messages per 2 minutes.  
Note that will send 1 message per minute, not 2 messages, wait 2 minutes, ...

> Try this node please and tell me why only one message is forwarded instead of 2 if you click the inject node several times:

You have chosen to drop intermediate messages.  
That means that a message is sent, then all messages received in the next minute are thrown away.

You initially said "many messages are sent in a short period of time (like 10 / sec), but they should be forwarded in fixed time slots (like 1 every 5 sec)", However the flow is rate limited 1 per minute.  
Perhaps you can clearly describe exactly what you want to achieve, the real rate of incoming messages and the rate you actually want to forward them.

---

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [18 November 2022 14:37 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/7 "2022-11-18T14:37:07Z")

</div>

I am checking the availability of a server every second.

If the server goes down I would like to send 2 messages to two receipients. As long as the server stays down I would like to re-send these two messages every 5 minutes.

The idea was to configure the delay node to "Send 2 msg / 5 min" and skip or delete all messages in between (because they are nevertheless re-sent every second).

But it seems that "2 msg / 5min" does not work as expected ...

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [18 November 2022 15:01 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/8 "2022-11-18T15:01:16Z")

</div>

you want two of the same message sent every 5 minutes? simply connecting the single message out to two different (I assume) email nodes will create two emails, etc.

please post your flow using the "`</>`" icon or simply wrap your flow code in ``` before and after.

---

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [18 November 2022 15:16 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/9 "2022-11-18T15:16:43Z")

</div>

I want a similar message with two different receipients to be sent every 5 minutes, although on the input-side once a second a new input us generated

See the example below: I want to send one message with "Dad" and one with "Mom" in parallel. After that I want to pause for 5 Minutens and re-send one with "Dad" and one with "Mom" again ... forever

```auto
[{"id":"3086e47410af607f","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"b2b2c3628bb65d20","type":"inject","z":"3086e47410af607f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":"3","topic":"","payload":"","payloadType":"date","x":210,"y":200,"wires":[["2a1be6e2687cba71"]]},{"id":"69a2808014af0b46","type":"delay","z":"3086e47410af607f","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"5","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":580,"y":200,"wires":[["7baf9ee4643e4171"]]},{"id":"7baf9ee4643e4171","type":"debug","z":"3086e47410af607f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":200,"wires":[]},{"id":"2a1be6e2687cba71","type":"function","z":"3086e47410af607f","name":"","func":"msg.recipient = \"Dad\";\nnode.send(msg);\nmsg.recipient = \"Mom\";\nnode.send(msg);\n\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":200,"wires":[["69a2808014af0b46"]]}]

```

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [18 November 2022 15:29 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/10 "2022-11-18T15:29:00Z")

</div>

Split your flow where the common data is all there and now you need to change message specific things for different recipients or whatever.

```auto
[{"id":"b2b2c3628bb65d20","type":"inject","z":"3086e47410af607f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":"3","topic":"","payload":"","payloadType":"date","x":150,"y":220,"wires":[["69a2808014af0b46"]]},{"id":"69a2808014af0b46","type":"delay","z":"3086e47410af607f","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":340,"y":220,"wires":[["3b9b8ade1bd15c83","898ae5f530a41476"]]},{"id":"7baf9ee4643e4171","type":"debug","z":"3086e47410af607f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":160,"wires":[]},{"id":"3b9b8ade1bd15c83","type":"change","z":"3086e47410af607f","name":"","rules":[{"t":"set","p":"recipient","pt":"msg","to":"Dad","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":160,"wires":[["7baf9ee4643e4171"]]},{"id":"898ae5f530a41476","type":"change","z":"3086e47410af607f","name":"","rules":[{"t":"set","p":"recipient","pt":"msg","to":"Mom","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":280,"wires":[["cca66198d9d467b1"]]},{"id":"cca66198d9d467b1","type":"debug","z":"3086e47410af607f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":280,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 November 2022 18:30 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/11 "2022-11-18T18:30:22Z")

</div>

Does this flow provide what you are aiming for?

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e1976d00ff31f420150078214245836901096859.jpeg)

```auto
[{"id":"b2b2c3628bb65d20","type":"inject","z":"3086e47410af607f","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"3","topic":"","payload":"Server unavailable","payloadType":"str","x":150,"y":80,"wires":[["542cb60982562a56"]]},{"id":"11233d047dedc706","type":"inject","z":"3086e47410af607f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Server available","payloadType":"str","x":140,"y":120,"wires":[["542cb60982562a56"]]},{"id":"55c2988aac1b456b","type":"rbe","z":"3086e47410af607f","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":370,"y":100,"wires":[["98d7d2b3956c8a6c","4683a60bd6e49150"]]},{"id":"98d7d2b3956c8a6c","type":"trigger","z":"3086e47410af607f","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"Server available","bytopic":"all","topic":"topic","outputs":1,"x":560,"y":220,"wires":[["52ff2f87395ec97b"]]},{"id":"160b59194dda993d","type":"debug","z":"3086e47410af607f","name":"Message to Dad","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":120,"wires":[]},{"id":"fcf322f8e712ce77","type":"comment","z":"3086e47410af607f","name":"Simulated input messages","info":"","x":150,"y":40,"wires":[]},{"id":"78fb6010bf9ea758","type":"comment","z":"3086e47410af607f","name":"Block duplicates","info":"","x":400,"y":60,"wires":[]},{"id":"9cce780e0d8b557a","type":"debug","z":"3086e47410af607f","name":"Message to Mom","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":80,"wires":[]},{"id":"491613437fb03450","type":"debug","z":"3086e47410af607f","name":"Message to Dad","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":240,"wires":[]},{"id":"7fbc155a0155a613","type":"debug","z":"3086e47410af607f","name":"Message to Mom","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":200,"wires":[]},{"id":"d747d7fd24cbf205","type":"comment","z":"3086e47410af607f","name":"Resend after 5 minutes unless \"Server available\"","info":"","x":680,"y":160,"wires":[]},{"id":"542cb60982562a56","type":"junction","z":"3086e47410af607f","x":280,"y":100,"wires":[["55c2988aac1b456b"]]},{"id":"4683a60bd6e49150","type":"junction","z":"3086e47410af607f","x":680,"y":100,"wires":[["160b59194dda993d","9cce780e0d8b557a"]]},{"id":"52ff2f87395ec97b","type":"junction","z":"3086e47410af607f","x":680,"y":220,"wires":[["491613437fb03450","7fbc155a0155a613"]]}]

```

(I have changed the delay from 5m to 5s for convenience)

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [19 November 2022 01:15 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/12 "2022-11-19T01:15:51Z")

</div>

Just move your function after the rate limiting and it will send 2 messages every 5 mins.

```auto
[{"id":"b2b2c3628bb65d20","type":"inject","z":"3086e47410af607f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":"3","topic":"","payload":"","payloadType":"date","x":210,"y":200,"wires":[["69a2808014af0b46"]]},{"id":"69a2808014af0b46","type":"delay","z":"3086e47410af607f","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":400,"y":200,"wires":[["2a1be6e2687cba71"]]},{"id":"7baf9ee4643e4171","type":"debug","z":"3086e47410af607f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":200,"wires":[]},{"id":"2a1be6e2687cba71","type":"function","z":"3086e47410af607f","name":"","func":"msg.recipient = \"Dad\";\nnode.send(msg);\nmsg.recipient = \"Mom\";\nnode.send(msg);\n\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":200,"wires":[["7baf9ee4643e4171"]]}]

```

---

<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 January 2023 01:16 UTC](https://discourse.nodered.org/t/aynchronous-wait-node/70825/13 "2023-01-18T01:16:41Z")

</div>

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