# Modbus Failure on State Sending

**URL:** https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942
**Category:** General
**Created:** [18 November 2021 13:55 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942 "2021-11-18T13:55:14Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)
#### Post date: [18 November 2021 13:55 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/1 "2021-11-18T13:55:14Z")

</div>

I have a code, that sends data over modbus to a device. it works. But every so often, i get a warning:  
"Modbus Failure on State sending Get more about it by logging"

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/559f1c17330f64ebd8bb9e4c2ebfadb1b59b24ff.png)

I'm not even sending data at the moment and I get this warning..  
What is this error? How do I "log" it to get more information?

---

<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 November 2021 15:29 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/2 "2021-11-18T15:29:14Z")

</div>

> [@traderjoe](#):
>
> I'm not even sending data at the moment and I get this warning

Are you absolutely certain of that? Click the node id above the message and it will take you to the node generating the error, then add a debug node showing what is going into that node to check you are not passing it anything.

---

<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: [18 November 2021 18:55 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/3 "2021-11-18T18:55:52Z")

</div>

> [@traderjoe](#):
>
> I'm not even sending data at the moment and I get this warning..

maybe the Modbus Config Node tries by itself to reconnect, if the **Reconnect on timeout** is checked.

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

regardless, there is a problem with the connection.

1. When you see this error, does the modbus connection ever recover or do you have to restart Node-red?
2. There were a few important issues fixed with the latest release **v5.15.0** of the Modbus nodes.  
What version version do you have and what version of Node.js ?

---

<div class="post-metadata">

### Author: ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)
#### Post date: [18 November 2021 20:07 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/4 "2021-11-18T20:07:02Z")

</div>

Hi,  
I did and it shows a modbus flex write node. I put a debug node in front to monitor the payload, and I see nothing when the error/warning is thrown.

---

<div class="post-metadata">

### Author: ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)
#### Post date: [18 November 2021 20:10 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/5 "2021-11-18T20:10:03Z")

</div>

My reconnect on Time out is checked.

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

My connection is good though. I'm reading from the this client the entire time. it's the modbus flex write that's giving me fits.

NR is telling me to log the errors to see more information. How do I do log the errors or pull the error logs?

---

<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: [18 November 2021 23:15 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/6 "2021-11-18T23:15:17Z")

</div>

> [@traderjoe](#):
>
> My connection is good though. I'm reading from the this client the entire time

hmm .. when you say "entire time" .. how often is that ? every second ? what happens if the modbus connection to that device is preoccupied because you are doing continuous reads and the write command fails. I dont know how modbus handles that but you can try increasing the **Queue delay** to allow the device to close the previous connection? (maybe)

> [@traderjoe](#):
>
> NR is telling me to log the errors to see more information. How do I do log the errors

Debug will be activated by starting Node-RED with debug mode  
You can read how to do that [here](https://github.com/BiancoRoyal/node-red-contrib-modbus#debug)

ps. you didnt tell us if you are on the latest version of Modbus nodes **v5.15.0**

---

<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: [19 November 2021 03:34 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/7 "2021-11-19T03:34:08Z")

</div>

after further testing .. i got some error also with the Modbus Read node. Seems they're still a bit buggy.

Try this flow that uses the **Flex Getter** and **Flex Write** instead and see if you get it to fail  
(edit appropriately to match your device settings)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/4027e0bf90a5748c15f49b20a31c46e25061b777.png)

```auto
[{"id":"7b1cceebbc6b3155","type":"debug","z":"54efb553244c241f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":300,"wires":[]},{"id":"accdd8a5e0ae9d64","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":170,"y":320,"wires":[["d419c64748d8892d"]]},{"id":"70290fbbbe462b5e","type":"modbus-flex-getter","z":"54efb553244c241f","name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"ebeab3422d31a778","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":560,"y":320,"wires":[["7b1cceebbc6b3155"],[]]},{"id":"d419c64748d8892d","type":"function","z":"54efb553244c241f","name":"","func":"msg.payload = { value: msg.payload, 'fc': 1, 'unitid': 1, 'address': 1, 'quantity': 8 }\nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":320,"wires":[["70290fbbbe462b5e"]]},{"id":"89369c2bcbeb76ca","type":"debug","z":"54efb553244c241f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":480,"wires":[]},{"id":"acefe3edeaaea469","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[0,0,0,0,1,1,1,1]","payloadType":"json","x":160,"y":460,"wires":[["5d070261787e3b4f"]]},{"id":"5d070261787e3b4f","type":"function","z":"54efb553244c241f","name":"","func":"\n\n\nmsg.payload = { value: msg.payload, 'fc': 15, 'unitid': 1, 'address': 1, 'quantity': 8 }\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":500,"wires":[["c77cda57d306495e"]]},{"id":"c77cda57d306495e","type":"modbus-flex-write","z":"54efb553244c241f","name":"","showStatusActivities":true,"showErrors":true,"server":"ebeab3422d31a778","emptyMsgOnFail":false,"keepMsgProperties":false,"x":550,"y":500,"wires":[["89369c2bcbeb76ca"],[]]},{"id":"6e7c0a768c13e750","type":"modbus-queue-info","z":"54efb553244c241f","name":"","topic":"","unitid":1,"queueReadIntervalTime":1000,"lowLowLevel":25,"lowLevel":75,"highLevel":150,"highHighLevel":300,"server":"ebeab3422d31a778","errorOnHighLevel":false,"showStatusActivities":true,"updateOnAllQueueChanges":false,"updateOnAllUnitQueues":false,"x":980,"y":400,"wires":[[]]},{"id":"1b16fc2c2c07f65b","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,1,1,1,0,0,0,0]","payloadType":"json","x":160,"y":540,"wires":[["5d070261787e3b4f"]]},{"id":"ebeab3422d31a778","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.0.66","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"","unit_id":"0","commandDelay":"50","clientTimeout":"500","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

```

---

<div class="post-metadata">

### Author: ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)
#### Post date: [19 November 2021 19:51 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/8 "2021-11-19T19:51:34Z")

</div>

Hi,  
I'm on 5.13 nodes. I'm having trouble updating it to 5.15.

According to the debug messages, its happening with the flex write nodes. The project still works, but those warnings do concern me a bit. Thanks.

---

<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: [19 November 2021 20:19 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/9 "2021-11-19T20:19:44Z")

</div>

> [@traderjoe](#):
>
> I'm having trouble updating it to 5.15

hi .. can you give us some more information of what you tried to upgrade the modbus node and why you had trouble ?

From your `.node-red` folder run

```auto
npm install node-red-contrib-modbus

```

Its worth updating it because with the latest release they added better support for Node.js version 14.  
something changed in nodejs 14 and up and the tcp connection wasnt handled correctly with Modbus and it would hang. You can read more about it [here](https://github.com/BiancoRoyal/node-red-contrib-modbus/issues/236)

What OS are you on and whats your nodejs version by the way. From terminal run  
`node -v`

---

<div class="post-metadata">

### Author: ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)
#### Post date: [19 November 2021 21:59 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/10 "2021-11-19T21:59:45Z")

</div>

Thanks for your help. I'm going to get on this again after the holidays.  
I think part of the problem is I'm not able to get to the internet with my ethernet due to incorrect subnet mask.

---

<div class="post-metadata">

### Author: ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)
#### Post date: [30 November 2021 14:00 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/11 "2021-11-30T14:00:02Z")

</div>

Hi!  
Happy thanksgiving.  
Ok, back on this. Trying to update my modbus nodes. I puttied in and typed in that npm install script and I get this:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/1193ed08e9411e01e3d12ca0a409ccd43799eb9b.png)

No errors. But I go to node-red, manage palettes, and find that 5.13 is installed. I can't install 5.15 from manage palettes either.

---

<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: [30 November 2021 14:58 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/12 "2021-11-30T14:58:16Z")

</div>

Hello .. you dont seem to be in the `.node-red` folder

> [@UnborN](#):
>
> From your `.node-red` folder run
> 
> `npm install node-red-contrib-modbus`

or use the **Manage Palette** from the Editor

---

<div class="post-metadata">

### Author: ![traderjoe](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@traderjoe](https://discourse.nodered.org/u/traderjoe)
#### Post date: [30 November 2021 17:31 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/13 "2021-11-30T17:31:43Z")

</div>

OK, I get this in putty now:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/73db1ba5e093aa4577666928f69854675d35f22e.png)

Then if I try manage palette I get this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c57cb5c15bd6df23d8a3a40836755c55a610b2e.png)

The debug log here.  
[2021-11-30T17\_28\_23\_942Z-debug.log](https://discourse.nodered.org/uploads/short-url/zvmOlFZdex1afdrF2jDlKLU5XXq.log) (77.8 KB)

I can't make heads/tails out of this.

---

<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: [30 November 2021 19:14 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/14 "2021-11-30T19:14:56Z")

</div>

```auto
error Refusing to delete /home/pi/.node-red/node_modules/modbus-serial/node_modules/.bin/prebuild-install: is outside /home/pi/.node-red/node_modules/modbus-serial/node_modules/prebuild-install and not a link
error File exists: /home/pi/.node-red/node_modules/modbus-serial/node_modules/.bin/prebuild-install

```

Im no npm expert but try again these steps  
first from `/home/pi/` folder run

`npm uninstall node-red-contrib-modbus`

(this is to ensure there are no remnants of the wrong folder installation you did before)

* * *

.. then from `.node-red` folder

`npm uninstall node-red-contrib-modbus`

`npm cache clean`

`npm install node-red-contrib-modbus `

* * *

If the above fails again .. then carefuly delete **only** the `node_modules` folder from `.node-red` and run  
`npm install`

---

<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: [14 December 2021 19:15 UTC](https://discourse.nodered.org/t/modbus-failure-on-state-sending/53942/15 "2021-12-14T19:15:20Z")

</div>

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