After automatic reconnection, tags are not readable and throw TIMEOUT error
May be related to Issue #56
Steps to reproduce:
- 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.)
-
Wait a while and start reading tags repeatedly using
plc.readTag() -
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.
-
After a moment, the
readTag()function starts to throw errors, and theplc.establishedproperty changes tofalse. -
Wait a few moments, then restore the PLC's connectivity.
-
After a moment, the
plc.establishedproperty turns totrueagain, indicating that the library has reconnected to the PLC. However, any subsequent attempts to executeplc.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)
… …
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.