Cloud-Automation / node-modbus

Modbus TCP Client/Server implementation for Node.JS
465 stars 174 forks source link

ECONNRESET #233

Closed MrWackers closed 5 years ago

MrWackers commented 5 years ago
const modbus = require('jsmodbus')
        const net = require('net')
        const server = new net.Server()
        const mbserver = new modbus.server.TCP(server)

        server.listen(502)

The Code block above works, but on client disconnect i get:

Error: read ECONNRESET
    at _errnoException (util.js:992:11)
    at TCP.onread (net.js:618:25)

This is just a strait disconnect I dont know why it would be causing errors.

the code that I'm really working with is

var netServer = new net.Server();

            netServer.on('error', (err) => {
                console.log('erro!');
                throw err;
            });

            this.server = new modbus.server.TCP(netServer, {
                holding: holding
            });

            this.server.on('connection', function (client) {
                console.log('New Connection')
            });

            this.server.on('error', (err) => {
                console.log('erro!');
                throw err;
            });

            netServer.listen(502);

and i just cant seem to make it stop. netServer.on('error' will not catch it either.

stefanpoeter commented 5 years ago

Are you executing any requests after the disconnect on the client?

MrWackers commented 5 years ago

It was when the CLient disconnected from the server. there could be a request but i dont think so.

I ended up muting it by doing the following.

var netServer = new net.Server(function(s){
                s.on('error', (err) => {
                });
            });
stefanpoeter commented 5 years ago

What client are you using?

MrWackers commented 5 years ago

Intellution IGS Driver

stefanpoeter commented 5 years ago

Can you snif the network traffic with wireshark or tcpdump so we get a better look at what is happening?