# Node-red-contrib-modbus stop execution in case of connection issue

**URL:** <https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802>\
**Category:** General\
**Created:** [18 December 2023 09:33 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802 "2023-12-18T09:33:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newmann](https://avatars.discourse-cdn.com/v4/letter/n/43a26b/32.png) [@Newmann](https://discourse.nodered.org/u/Newmann)\
**Post date:** [18 December 2023 09:33 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802/1 "2023-12-18T09:33:23Z")

</div>

Hello All,

I have to implement a flow where if node-red-copntrib-modbus cannot connect to a MOXA device, then I need to interrupt the flow execution and send back a http failure result.  
So far, I couldn't reach the point, in case if I am setting an invalid IP, which of course unreachable, the nodes stuck in initialize state forever, and the catch node didn't log anything in my test flow.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/50e604b1183018223aa3892746d7a4880367087f.png)  
Is it possible to setup this scenario with node-red-contrib-modbus?

Thank you!

Rp

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 December 2023 10:54 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802/2 "2023-12-18T10:54:54Z")

</div>

The status node can be used to "watch" the status of the flex-getter nodes.

---

<div class="post-metadata">

**Author:** ![Newmann](https://avatars.discourse-cdn.com/v4/letter/n/43a26b/32.png) [@Newmann](https://discourse.nodered.org/u/Newmann)\
**Post date:** [18 December 2023 12:31 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802/3 "2023-12-18T12:31:33Z")

</div>

Hello Steve,

Thank you for your answer, I tried to set it up, probably I missed something, but it doesn't seem so reliable:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/62dba2e10231ece8f111e98f55cc3849f1349bd3.png)  
As you can see, it's in initialize state, but on the debug window you can see the status is green. Based on the debug logs, even if I can see yellow and initialize on the screen, and it's not changing, the last status reported by the status node is always green. I guess in one point of time it will change, and maybe then it will follow the actual state, but till that it's not works properly.  
Did you also experienced this issue, or I set something incorrectly?  
Is there any more advanced way to handle it?

Thanks,

Rp

---

<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:** [18 December 2023 13:48 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802/4 "2023-12-18T13:48:28Z")

</div>

The status node may not pick up the first status following a restart (or if the modbus node is re-deployed). Could that be the situation here?

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [28 December 2023 07:51 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802/5 "2023-12-28T07:51:31Z")

</div>

Hello @Newmann

A more reliable way of catching errors with the Modbus nodes (instead of using Status or Catch nodes)  
is by enabling the option " **Empty msg on Modbus Fail**" on the Modbus Flex Getter.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9baf8df9cf1af25115966b5726a3bdcaaaabf232.png)

In case of a failure this will produce a msg with a property `error` and empty `payload`  
that you can then look for and handle appropriately.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/14f495d3b0887b1c6f272673358ade0185a65453.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:** [26 February 2024 07:52 UTC](https://discourse.nodered.org/t/node-red-contrib-modbus-stop-execution-in-case-of-connection-issue/83802/6 "2024-02-26T07:52:16Z")

</div>

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