# Delay node can not work with multi topic with different msg.rate

**URL:** <https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286>\
**Category:** General\
**Created:** [9 May 2023 04:00 UTC](https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286 "2023-05-09T04:00:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bjdaijun](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bjdaijun/32/75846_2.png) [@bjdaijun](https://discourse.nodered.org/u/bjdaijun)\
**Post date:** [9 May 2023 04:00 UTC](https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286/1 "2023-05-09T04:00:38Z")

</div>

```auto
[
    {
        "id": "e96b3cf4329c5f4a",
        "type": "inject",
        "z": "d70eb72327dc3f2e",
        "name": "Node1",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 200,
        "wires": [
            [
                "b4486d7bda88c94b"
            ]
        ]
    },
    {
        "id": "a98f535fcde0bd82",
        "type": "inject",
        "z": "d70eb72327dc3f2e",
        "name": "Node2",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 240,
        "wires": [
            [
                "a86b125b73f7bf56"
            ]
        ]
    },
    {
        "id": "f9dd0dd191b3d3fb",
        "type": "delay",
        "z": "d70eb72327dc3f2e",
        "name": "",
        "pauseType": "timed",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "5",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": true,
        "outputs": 2,
        "x": 630,
        "y": 220,
        "wires": [
            [
                "b637dea8b0153dda"
            ],
            []
        ]
    },
    {
        "id": "b4486d7bda88c94b",
        "type": "function",
        "z": "d70eb72327dc3f2e",
        "name": "fun1",
        "func": "msg.topic=\"1111\"\nmsg.rate=5000\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 200,
        "wires": [
            [
                "c02eaad562f17b9b"
            ]
        ]
    },
    {
        "id": "a86b125b73f7bf56",
        "type": "function",
        "z": "d70eb72327dc3f2e",
        "name": "fun2",
        "func": "msg.topic=\"2\"\nmsg.rate=10000\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 240,
        "wires": [
            [
                "c02eaad562f17b9b"
            ]
        ]
    },
    {
        "id": "b637dea8b0153dda",
        "type": "debug",
        "z": "d70eb72327dc3f2e",
        "name": "debug 86",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 800,
        "y": 200,
        "wires": []
    },
    {
        "id": "c02eaad562f17b9b",
        "type": "junction",
        "z": "d70eb72327dc3f2e",
        "x": 500,
        "y": 220,
        "wires": [
            [
                "f9dd0dd191b3d3fb"
            ]
        ]
    }
]

```

As the flow shows, the debug show nothing with two branch of messages.

But if I delete node2 , only has Node2 send message, then the debug node will show message.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 May 2023 05:30 UTC](https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286/2 "2023-05-09T05:30:21Z")

</div>

You may need to explain it for people like me.

I don't understand what you want and what you are getting.

Please try to:  
Explain what you want to happen.  
What is happening.

---

<div class="post-metadata">

**Author:** ![bjdaijun](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bjdaijun/32/75846_2.png) [@bjdaijun](https://discourse.nodered.org/u/bjdaijun)\
**Post date:** [9 May 2023 05:37 UTC](https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286/3 "2023-05-09T05:37:09Z")

</div>

I want node1 and node2 out put message with different rate, but seems use delay node can't achive it.

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [9 May 2023 06:06 UTC](https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286/4 "2023-05-09T06:06:59Z")

</div>

That is not possible with a single delay node.  
If you check the [code in line 249](https://github.com/node-red/node-red/blob/67dd7e30faf1a6fca07f5b745de75f4ad3036ce4/packages/node_modules/%40node-red/nodes/core/function/89-delay.js#L249) (and the functionality is similar for all modes of operation) you can see that `msg.rate` is not stored based on the `msg.topic`.  
In [line 250](https://github.com/node-red/node-red/blob/67dd7e30faf1a6fca07f5b745de75f4ad3036ce4/packages/node_modules/%40node-red/nodes/core/function/89-delay.js#L250) you can see that the timeout is reset, hence you will not get any output, because your timer is reset with every message delivering `msg.rate` (at a rate of 1msg/sec).

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 May 2023 06:34 UTC](https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286/5 "2023-05-09T06:34:53Z")

</div>

I am seeing weird things when I run a SIMILAR flow.

```auto
[{"id":"6db7a285e85762b4","type":"delay","z":"d188b95f33e5f7e4","name":"","pauseType":"timed","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":true,"outputs":2,"x":1240,"y":3610,"wires":[["4977aa834ee57c10"],["a1a1deeea2e90997"]]},{"id":"1ade33a3d7ca52ca","type":"function","z":"d188b95f33e5f7e4","name":"fun3","func":"msg.topic=\"33\"\nmsg.rate=5000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3610,"wires":[["6db7a285e85762b4"]]},{"id":"76353e11e8441739","type":"function","z":"d188b95f33e5f7e4","name":"fun2","func":"msg.topic=\"2\"\nmsg.rate=10000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3560,"wires":[["6db7a285e85762b4"]]},{"id":"18bf251fef88f1f8","type":"function","z":"d188b95f33e5f7e4","name":"fun1","func":"msg.topic=\"1111\"\nmsg.rate=5000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3520,"wires":[["6db7a285e85762b4"]]},{"id":"673809bc521ae1d5","type":"trigger","z":"d188b95f33e5f7e4","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-250","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1160,"y":3670,"wires":[["6db7a285e85762b4"]]},{"id":"a11eb9420d53a580","type":"trigger","z":"d188b95f33e5f7e4","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-250","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1160,"y":3710,"wires":[["6db7a285e85762b4"]]},{"id":"4977aa834ee57c10","type":"debug","z":"d188b95f33e5f7e4","name":"debug 270","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1400,"y":3540,"wires":[]},{"id":"a1a1deeea2e90997","type":"debug","z":"d188b95f33e5f7e4","name":"Intermediate output","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1420,"y":3720,"wires":[]},{"id":"c7010cbdb412e550","type":"inject","z":"d188b95f33e5f7e4","name":"Node3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Node 3","payloadType":"str","x":820,"y":3610,"wires":[["1ade33a3d7ca52ca"]]},{"id":"7eefe41464f65f7b","type":"inject","z":"d188b95f33e5f7e4","name":"Node2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 2","payloadType":"str","x":820,"y":3560,"wires":[["76353e11e8441739"]]},{"id":"f8bdb55903341aae","type":"inject","z":"d188b95f33e5f7e4","name":"Node1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 1","payloadType":"str","x":820,"y":3520,"wires":[["18bf251fef88f1f8"]]},{"id":"fd7a89c2649053cd","type":"function","z":"d188b95f33e5f7e4","name":"fun1","func":"msg.topic=\"1111\"\nmsg.rate=5000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3670,"wires":[["673809bc521ae1d5"]]},{"id":"afd3d945bc9fdb01","type":"inject","z":"d188b95f33e5f7e4","name":"STOP 1","props":[{"p":"reset","v":"reset","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":980,"y":3750,"wires":[["673809bc521ae1d5"]]},{"id":"d057efe30abab42e","type":"function","z":"d188b95f33e5f7e4","name":"fun2","func":"msg.topic=\"2\"\nmsg.rate=10000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":3710,"wires":[["a11eb9420d53a580"]]},{"id":"bdbc863e7e4c0c3b","type":"inject","z":"d188b95f33e5f7e4","name":"STOP 2","props":[{"p":"reset","v":"reset","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":980,"y":3790,"wires":[["a11eb9420d53a580"]]},{"id":"10e13db9a9a5e701","type":"inject","z":"d188b95f33e5f7e4","name":"Start 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 1","payloadType":"str","x":820,"y":3670,"wires":[["fd7a89c2649053cd"]]},{"id":"bda80a4f1df7258a","type":"inject","z":"d188b95f33e5f7e4","name":"Start 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"Node 2","payloadType":"str","x":820,"y":3710,"wires":[["d057efe30abab42e"]]}]

```

(Standard nodes)

When thing are happening - as per your first post - nothing happens.

But if you lick either of the top3 (well forget the #3 node) you SOMETIMES get an output.  
This is helped if you maybe press the node at slightly quicker than once a second.  
And you need to do it for at least 10 seconds. Maybe 15.

Ok: slight correction:  
Let it run for a while then STOP #2 (or 1) and keep pressing the upper #1 button. (Or the one which is still running)

You start to get outputs at the time set.

Frantically pressing this button.  
Here's what I see.

 ![Screenshot from 2023-05-09 16-42-14](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e7592e63bf160f225ff7895dfe92615df363e2f.png)

---

<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:** [23 May 2023 06:35 UTC](https://discourse.nodered.org/t/delay-node-can-not-work-with-multi-topic-with-different-msg-rate/78286/6 "2023-05-23T06:35:28Z")

</div>

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