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

Process crash when using destroy methods

Open aurelhann opened this issue 4 years ago • 0 comments

Current Behavior

On a specific devices or/and particular network failures , use the destroy method to ends the devices connection will end all the process

10 Jan 11:09:35 - Error: This socket has been ended by the other party
    at Controller.writeAfterFIN [as write] (net.js:407:14)
    at Controller.destroy (/home/aurelien/repos/braincubeiot2-contrib-ethernetip/.bin/red/ethernetip.js:1118:14)
    at destroyPLC (/home/aurelien/repos/braincubeiot2-contrib-ethernetip/.bin/red/ethernetip.js:8162:31)

Expected Behavior

Normally when a socket is gone don't try to write something on it.

Possible Solution (Optional)

Apply this changement in your destroy method like that

destroy(exception) {
        const { unregisterSession } = encapsulation;
        if(this.destroyed) return ;
        this.write(unregisterSession(this.state.session.id), () => {
            this.state.session.established = false;
            super.destroy();
        });
    }

Context

My connection pass through a proxy and fucked up some times. And close connections.

Steps to Reproduce (for bugs only)

  1. Make a connection to your plc
  2. Disconnect it mecanicly
  3. Apply the destroy method
  4. See whats happened !

Your Environment

  • Package version (Use npm list - e.g. 1.0.6): 6.9.0
  • Node Version (Use node --version - e.g. 9.8.0): 12.2.0
  • Operating System and version: linux debian 10
  • Controller Type (eg 1756-L83E/B): 1756-L83
  • Controller Firmware (eg 30.11): 30.12

aurelhann avatar Jan 10 '20 10:01 aurelhann