plcpeople / nodeS7

Node.JS library for communication to Siemens S7 PLCs
MIT License
363 stars 122 forks source link

S7Endpoint does not reconnect automatically on transport error #103

Closed gfcittolin closed 4 years ago

gfcittolin commented 4 years ago

Testing the following snippet (autoReconnect in the default value, 5000 ms), S7Endpoint does not try to reconnect again:

const { S7Endpoint } = require('nodes7');

console.log('Connecting to PLC...')
let plc = new S7Endpoint({ host: '192.168.15.123', slot: 1 });

plc.on('connect', () => console.log('PLC#connect'));
plc.on('error', e => console.log('PLC#error', e));
plc.on('disconnect', () => console.log('PLC#disconnect'));

The issue seems to be related to a double-cleanup of the connection, resulting in the reconnect timer from the first attempt being cleaned-up.

As discovered in #98

gfcittolin commented 4 years ago

Duplicate of #101, following the issue there