ST-node-ethernet-ip icon indicating copy to clipboard operation
ST-node-ethernet-ip copied to clipboard

After automatic reconnection, tags are not readable and throw TIMEOUT error

Open ryangriggs opened this issue 1 year ago • 1 comments

May be related to Issue #56

Steps to reproduce:

  1. Connect to a CompactLogix PLC using:
const plc = new Controller()
plc.connect(ip_address, slot);

(At this point the plc.established property changes to true to indicate an active connection.)

  1. Wait a while and start reading tags repeatedly using plc.readTag()

  2. After tags are reading successfully, unplug the PLC's Ethernet cable, power it off, or change its' IP address, causing a loss of connectivity to the PLC.

  3. After a moment, the readTag() function starts to throw errors, and the plc.established property changes to false.

  4. Wait a few moments, then restore the PLC's connectivity.

  5. After a moment, the plc.established property turns to true again, indicating that the library has reconnected to the PLC. However, any subsequent attempts to execute plc.readTag() fail with the following error: (note that the tag being read in this example is named "Int1" and is a Controller-scoped tag.

All subsequent readTag() functions fail until a new plc.connect(...) function is issued, at which point everything starts reading again.

Error: TIMEOUT occurred while writing Reading Tag: Int1.
at Controller._readTag ([snip]\node_modules\st-ethernet-ip\dist\controller\index.js:727:28)
at TaskEasy._runTask ([snip]\node_modules\task-easy\src\index.js:118:9)
at TaskEasy._next ([snip]\node_modules\task-easy\src\index.js:138:18)
at [snip]\node_modules\task-easy\src\index.js:56:22
at new Promise (<anonymous>)
at TaskEasy.schedule ([snip]\node_modules\task-easy\src\index.js:51:16)\
at Controller.readTag ([snip]\node_modules\st-ethernet-ip\dist\controller\index.js:591:34
at Driver_EthernetIP.read ([snip]\Driver_EthernetIP.class.js:150:19)
 … …

ryangriggs avatar Apr 27 '24 19:04 ryangriggs

plc reconnections are not handled on the base class Controller. Use the extController or ControllerManager class or you can look at its code to see how disconnects are handled there to roll your own controller error handling.

SerafinTech avatar Jun 13 '24 01:06 SerafinTech