node-modbus-serial icon indicating copy to clipboard operation
node-modbus-serial copied to clipboard

'close' event is not firing after v8.0.19

Open canegru opened this issue 5 months ago • 1 comments

We currently hook into the client.on('close', () => events for our reconnect logic, and after version v8.0.19 the event is not being emitted due to #578 .

I've been able to replicate this issue locally on my own machine as well as in a production environment, reading from a PLC.

await connectionClient.connectTCP(this.configuration.endpointUrl, {
    port: this.configuration.endpointPort ?? 502,
    keepAlive: true,
});
connectionClient.on('close', () => {
    this.logger.log('Modbus connection closed');
});
connectionClient.on('error', () => {
    this.logger.error('Modbus connection error');
});

I'm a bit busy this week, but I can dig into the code if no one has time.

The current fix is to use 8.0.18.

canegru avatar May 12 '25 18:05 canegru