jisotalo / ads-client

Unofficial Node.js ADS library for connecting to Beckhoff TwinCAT automation systems using ADS protocol.
https://jisotalo.fi/ads-client/
MIT License
80 stars 17 forks source link

Uncaught exception ECONNRESET after restarting PLC #84

Closed dotKokott closed 2 years ago

dotKokott commented 2 years ago

Hello,

I would like to be able to brace for a power outage of the PLC (including the switch that connects the PLC to the computer running node-ads).

When I turn off the power cabinet I get a connectionLost which is correct. However when it comes back online I get a

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

which I assume happens when it is trying to reconnect.

I am not sure how to catch this error. I would be fine with catching this moment and attempting the reconnection myself, however this crashes my whole application.

I already upgraded to the latest version 1.5.1

jisotalo commented 2 years ago

Hi!

Are you sure you are using the newest version? Newest is 1.12.1 (not 1.5.1) and 1.12.0 incluled lots of optimizations to connection handling.

dotKokott commented 2 years ago

Oh my bad. I was indeed on the wrong version!

jisotalo commented 2 years ago

@dotKokott thanks for reporting! I assume it worked with newest version?

dotKokott commented 2 years ago

Yes it works now! thank you very much :)