Modbus-Flex-Server stops working

Hello,
I have created a modbus-flex-server using node-red-contrib-modbus so that another PC can log data for energy monitoring. The data transfer works until the Modbus program is closed on the other PC. Then I get the error message:

11 Apr 07:13:56 - [warn] [modbus-flex-server:Server weather station] Error: read ECONNRESET

Once I get the error message, I can no longer read data from the modbus-server until I restart Node-RED.

I also tested this with the program qModMaster:

When I connect and close the program, the error message comes up.

When I connect, disconnect and close the program, the error message doesn't come up.

Can I change something in Node-Red so that the modbus-server works again when the error message comes

Node Red: 2.1.6

node-red-contrib-modbus: 5.16.0

OS: Windows 10

My Flow:

[
    {
        "id": "77de1006ed0ee9ad",
        "type": "modbus-flex-server",
        "z": "d2ef54c17e2c6eb4",
        "name": "Server Wetterstation",
        "logEnabled": false,
        "serverAddress": "10.46.35.205",
        "serverPort": "502",
        "responseDelay": "50",
        "unitId": 1,
        "delayUnit": "ms",
        "coilsBufferSize": "0",
        "registersBufferSize": "20",
        "minAddress": 0,
        "splitAddress": "10",
        "funcGetCoil": "function getFlexCoil(addr, unitID) {\n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\treturn node.coils.readUInt8(addr * node.bufferFactor) \n\t}  \n}",
        "funcGetDiscreteInput": "function getFlexDiscreteInput(addr, unitID) {\n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.coils.readUInt8(addr * node.bufferFactor) \n\t}  \n}",
        "funcGetInputRegister": "function getFlexInputRegister(addr, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor)  \n\t} \n}",
        "funcGetHoldingRegister": "function getFlexHoldingRegsiter(addr, unitID) { \n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor)  \n\t} \n}",
        "funcSetCoil": "function setFlexCoil(addr, value, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\tnode.coils.writeUInt8(value, addr * node.bufferFactor)  \n\t} \n}",
        "funcSetRegister": "function setFlexRegister(addr, value, unitID) { \n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\tnode.registers.writeUInt16BE(value, addr * node.bufferFactor)  \n\t} \n}",
        "showErrors": true,
        "x": 920,
        "y": 280,
        "wires": [
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "130d97601d6dd247",
        "type": "function",
        "z": "d2ef54c17e2c6eb4",
        "name": "write 0-1",
        "func": "var value=msg.payload;\nbuf=Buffer.alloc(4);\nbuf.writeFloatBE(value);\nvar value1=(buf[0]*256+buf[1]);\nvar value2=(buf[2]*256)+buf[3];\n\nmsg.payload = { 'value': value1,\n    'register': 'holding',\n    'address': 0 ,\n    'disableMsgOutput' : 1 \n};\n\nnode.send(msg);  \n msg.payload = { 'value': value2,\n    'register': 'holding',\n    'address': 1 ,\n    'disableMsgOutput' : 1\n };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 120,
        "wires": [
            [
                "77de1006ed0ee9ad"
            ]
        ]
    },
    {
        "id": "62d87a0b86a3d9c1",
        "type": "function",
        "z": "d2ef54c17e2c6eb4",
        "name": "write 4-5",
        "func": "var value=msg.payload;\nbuf=Buffer.alloc(4);\nbuf.writeInt32BE(value)\nvar value1=(buf[0]*256+buf[1]);\nvar value2=(buf[2]*256)+buf[3];\n\nmsg.payload = { 'value': value1,\n    'register': 'holding',\n    'address': 4 ,\n    'disableMsgOutput' : 1 \n};\n\nnode.send(msg);  \n msg.payload = { 'value': value2,\n    'register': 'holding',\n    'address': 5 ,\n    'disableMsgOutput' : 1\n };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 280,
        "wires": [
            [
                "77de1006ed0ee9ad"
            ]
        ]
    },
    {
        "id": "89d3ef35643e0908",
        "type": "function",
        "z": "d2ef54c17e2c6eb4",
        "name": "write 2-3",
        "func": "var value=msg.payload;\nbuf=Buffer.alloc(4);\nbuf.writeFloatBE(value);\nvar value1=(buf[0]*256+buf[1]);\nvar value2=(buf[2]*256)+buf[3];\n\nmsg.payload = { 'value': value1,\n    'register': 'holding',\n    'address': 2 ,\n    'disableMsgOutput' : 1 \n};\n\nnode.send(msg);  \n msg.payload = { 'value': value2,\n    'register': 'holding',\n    'address': 3 ,\n    'disableMsgOutput' : 1\n };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 200,
        "wires": [
            [
                "77de1006ed0ee9ad"
            ]
        ]
    },
    {
        "id": "e790070a8061b4d8",
        "type": "function",
        "z": "d2ef54c17e2c6eb4",
        "name": "write 6-7",
        "func": "var value=msg.payload;\nbuf=Buffer.alloc(4);\nbuf.writeFloatBE(value);\nvar value1=(buf[0]*256+buf[1]);\nvar value2=(buf[2]*256)+buf[3];\n\nmsg.payload = { 'value': value1,\n    'register': 'holding',\n    'address': 6 ,\n    'disableMsgOutput' : 1 \n};\n\nnode.send(msg);  \n msg.payload = { 'value': value2,\n    'register': 'holding',\n    'address': 7 ,\n    'disableMsgOutput' : 1\n };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 360,
        "wires": [
            [
                "77de1006ed0ee9ad"
            ]
        ]
    },
    {
        "id": "f310c64d0638c449",
        "type": "function",
        "z": "d2ef54c17e2c6eb4",
        "name": "write 8-9",
        "func": "flow.set('Regen_ges',msg.payload); //Regenmenge speichern\n\nvar value=msg.payload;\nbuf=Buffer.alloc(4);\nbuf.writeFloatBE(value);\nvar value1=(buf[0]*256+buf[1]);\nvar value2=(buf[2]*256)+buf[3];\n\nmsg.payload = { 'value': value1,\n    'register': 'holding',\n    'address': 8 ,\n    'disableMsgOutput' : 1 \n};\n\nnode.send(msg);  \n msg.payload = { 'value': value2,\n    'register': 'holding',\n    'address': 9 ,\n    'disableMsgOutput' : 1\n };\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 440,
        "wires": [
            [
                "77de1006ed0ee9ad"
            ]
        ]
    },
    {
        "id": "702dd68013e3558d",
        "type": "comment",
        "z": "d2ef54c17e2c6eb4",
        "name": "Modbus Client für RESMA",
        "info": "",
        "x": 930,
        "y": 200,
        "wires": []
    },
    {
        "id": "47ee50e4b162133b",
        "type": "status",
        "z": "d2ef54c17e2c6eb4",
        "name": "",
        "scope": [
            "77de1006ed0ee9ad"
        ],
        "x": 840,
        "y": 100,
        "wires": [
            [
                "c4b19bc781c90da0"
            ]
        ]
    },
    {
        "id": "c4b19bc781c90da0",
        "type": "debug",
        "z": "d2ef54c17e2c6eb4",
        "name": "ModbusServer",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1010,
        "y": 100,
        "wires": []
    }
]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.