# Something weird is happening with \`msg.delay\` and \`trigger\` node

**URL:** https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220
**Category:** General
**Created:** [2 March 2022 09:16 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220 "2022-03-02T09:16:51Z")
**Posts on this page:** 9
**Page:** 1

<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: [2 March 2022 09:16 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/1 "2022-03-02T09:16:51Z")

</div>

I have an `inject` node spitting out messages every 40 seconds.

I originally added a `msg.delay` to it, but a node into which the message went didn't pass on that, so I had to stick a `change` node after that to set `msg.delay`.  
(And I also ticked the `extend of message arrives` option)

Downstream, I have some `trigger` nodes.  
They were originally set to `120 seconds` as the time.  
But I decided to _cheat_ having to edit all these nodes I set the `override with msg.delay` so all I have to do is adjust that property.

So, I (stupidly) set the `msg.delay` to `120` (Yeah, I know - now)

Suddenly I was getting a lot of _alerts_ as the `trigger` nodes not getting a signal.

So I changed the value from `120` to `12000`.

Still getting them.

Thoughts?

---

<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: [2 March 2022 09:30 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/2 "2022-03-02T09:30:35Z")

</div>

Post an example flow that exhibits the problem, that we can test.

---

<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: [2 March 2022 09:44 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/3 "2022-03-02T09:44:42Z")

</div>

Code:

```auto
[{"id":"a9d28571.a909d8","type":"inject","z":"c56bddee.ca0a18","name":"WAP scan *","props":[{"p":"payload"}],"repeat":"40","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"1","payloadType":"num","x":180,"y":330,"wires":[["31e5b191.b8f056","f8a0810e.2d9378"]],"info":"Make sure `msg.delay` (set on second line) is a lot greater than the scan time."},{"id":"f8a0810e.2d9378","type":"pythonshell in","z":"c56bddee.ca0a18","name":"wifiscan","pyfile":"/home/pi/python_stuff/wifiscan.py","virtualenv":"","continuous":false,"stdInData":false,"x":550,"y":310,"wires":[["b1f4ee0993eb1635"]]},{"id":"b1f4ee0993eb1635","type":"change","z":"c56bddee.ca0a18","name":"delay (ms)","rules":[{"t":"set","p":"delay","pt":"msg","to":"120000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":655,"y":310,"wires":[["7d11f7e2.8ab188","bed0b75b24a7d023","f63974b5bff323ba","89c86f65.2dd438"]],"l":false},{"id":"89c86f65.2dd438","type":"split","z":"c56bddee.ca0a18","name":"Spliter","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":170,"y":510,"wires":[["ec424f64.9e3fb","80326bb7.b1ebd"]]},{"id":"ec424f64.9e3fb","type":"switch","z":"c56bddee.ca0a18","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Marys_Farm_2.4","vt":"str"},{"t":"cont","v":"PiNet","vt":"str"},{"t":"cont","v":"MusicPi","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":370,"y":510,"wires":[["a2ddf193.eb9b2","cbc7451e.882c48","6f85dabf.e8e8ec"],["b6d0e5a5.8c246","c4c40434.f4ab6"],["cf9bae6b.340e68","efb14f6c.1c6ba8"]]},{"id":"6f85dabf.e8e8ec","type":"change","z":"c56bddee.ca0a18","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":505,"y":420,"wires":[["e4d2eb6a.510b3","1bf0835ecc376fa6"]],"l":false},{"id":"1bf0835ecc376fa6","type":"trigger","z":"c56bddee.ca0a18","name":"Trigger (v)","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"60","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":710,"y":390,"wires":[["72f00882.b6efc8","375a3741.743c4","babc12dd.24df7"]]}]

```

I have a `python` script running to get WAP names.  
(You can bypass that)

There is a `change` node after that which sets the `msg.delay`. It is now set to 120000.  
It fails if it is set to 12000.  
The message is then sent down and `split` so each WAP name is a different line.  
That is then sent through a `switch` node and another `change` node to set the payload.  
Then it gets to the `trigger` node.

It keeps failing from what I can see.

The other `trigger` node (on the right) is also timing out.

 ![Screenshot from 2022-03-02 20-39-27](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f501caab22669ac34f48ef45f6c1f075a8e1ad43.png)

Sorry it is a mess. I bypassed a couple of foreign nodes.  
You will also have to edit the `switch` node (or actually probably remove it)  
and the `wifiscan` node won't work as it runs a python script.

---

<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: [2 March 2022 10:13 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/4 "2022-03-02T10:13:47Z")

</div>

Add a debug node showing what is going to the trigger node. Set the debug node so output Complete Message. Post it here.

---

<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: [2 March 2022 10:20 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/5 "2022-03-02T10:20:40Z")

</div>

From the `MAIN` debug node shown in the scree shot.

_Luckily_ shortly after posting things _timed out_.  
(I dropped the value from `120000` to `12000` - the latter should be 120 seconds, yes?

```auto
{"delay":12000,"settings":{"input":"2022-03-02T10:18:12.624Z","input_format":"","input_tz":"Australia/Sydney","output_format":"YYYY-MM-DD HH:mm:ss","output_locale":"en_AU","output_tz":"Australia/Sydney"},"time":"2022-03-02 21:18:12","payload":"[\"Marys_Farm_2.4\"","parts":{"id":"991ad92bb887a62a","type":"string","ch":",","index":0,"count":15},"_msgid":"bc6b209b383a30f3"}

```

---

<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: [2 March 2022 10:38 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/6 "2022-03-02T10:38:20Z")

</div>

This is another example on a different machine doing the same thing.

 ![Screenshot from 2022-03-02 21-32-04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3ce4c78c6b136674bfc6706c4cd21ee22c404e47.png)

```auto
[{"id":"77795cac0d658efe","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"12000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":3470,"y":140,"wires":[["a407ab20bbb005f3","d8b5834f552a5ea8"]]},{"id":"871d194d2d8dc437","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"40","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":3320,"y":190,"wires":[["d595285338d487f5","77795cac0d658efe"]]},{"id":"a407ab20bbb005f3","type":"trigger","z":"0918ee609bf69fc7","name":"","op1":"","op2":"FAIL","op1type":"nul","op2type":"str","duration":"250","extend":true,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":3670,"y":190,"wires":[["c4b2b9ae77efc369"]]},{"id":"d8b5834f552a5ea8","type":"debug","z":"0918ee609bf69fc7","name":"into trigger","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":3650,"y":90,"wires":[]},{"id":"d595285338d487f5","type":"trigger","z":"0918ee609bf69fc7","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":3310,"y":240,"wires":[[]]},{"id":"c4b2b9ae77efc369","type":"debug","z":"0918ee609bf69fc7","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":3660,"y":240,"wires":[]}]

```

---

<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: [2 March 2022 10:54 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/7 "2022-03-02T10:54:30Z")

</div>

You have set the delay to 12000 milliseconds . There are 1000 milliseconds in a second, so 12 seconds after the inject the trigger times out. What do you expect to happen?

---

<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: [2 March 2022 10:56 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/8 "2022-03-02T10:56:22Z")

</div>

Yeah, I'm stupid.

Alas somehow I thought it was `x100`.... That's not _milli_, but more _centi_.

Sorry.

---

<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: [16 March 2022 10:57 UTC](https://discourse.nodered.org/t/something-weird-is-happening-with-msg-delay-and-trigger-node/59220/9 "2022-03-16T10:57:20Z")

</div>

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