node-red-contrib-error-on-timeout 1.2.4
Node that triggers an error if a message is not received within the configured time frame. Also has an output for "late" messages.
node-red-contrib-error-on-timeout
Node red contribution node that triggers an error if a second message has not been received within a configurable timeframe.
Usage
This node receives at first a message with the eot_trigger
property set and then starts the delay until a message with the eot_input
flag arrives.
Warning
This node is not suitable for high frequency message processing. It is meant to help control the flow by checking a command / acknowledgement
pattern such as switching equipment on and off. See my use case.
Dead lock
Once the node receives a message with the eot_trigger
flag set, it'll be waiting for a message with the eot_input
flag and won't accept any more trigger messages untile the configured timeout has been triggered.
Outputs
- Success output: All messages that have arrived within the configured timeframe
- Error output: When no message arrives within the configured timeframe
- Late output: All messages that arrived after the configured timeframe
Programmatic configuration of the timeout interval
The message with the eot_trigger
property can have a eot_timeout
property set to the desired interval in milliseconds.
Latency stats
The following properties/fields are added to the messages coming out of each individual output of the node:
| Output | Fields | |--- |--- | | Success |
eot_timeout
Configured timeout in millisecondseot_time
Time in milliseconds it took until the expected message arrived
topic
is set toerror-on-timeout
payload
Formatted error message readingInput message not received within ${timeout} ms
eot_trigger
A copy of the message that triggered the timer that resulted in the timeout
eot_timeout
Configured timeout in millisecondseot_time
Time in milliseconds it took until the late message arrivedeot_late
Late time in milliseconds
My use case
I'm working on an IoT project running on MQTT where successfull execution of commands is crucial. After sending a command to a device I needed to ensure that the command has been executed successfully by having the device send out an ack
message within a certain timeframe before turning on other heavy duty equipment (and potentially blow up the entire infrastructure).
sequenceDiagram
Actor Node Red
Actor Selenoid
Actor Pump
Node Red->>Selenoid: Open
Selenoid->>Node Red: ACK
Node Red->>Pump: Run
Pump->>Node Red: ACK
The default nodes that come with Node Red seemed to be too... redundant for my needs and I preferred to develop something simple and concise and wrap it into a node.
I sincerely do hope that you make good use of it.
Please see the examples by importing them through the Import > Examples dialog.