ITADN

modbus-flex-server dropping port after ECONNRESET

#548Closednaanatin 创建于 2025-10-15
bugStale
N
naanatincommented
### Which node-red-contrib-modbus version are you using? contrib-modbus 5.44.1, contrib-modbus-flex-server 1.0.1 ### What happened? I have a flex-server node (named "Modbus Slave") that is listening on TCP port 11502. Every now and then (after a few days or few weeks) the node has an ECONNRESET and produces an error `Oct 10 10:20:09 <myserver> node-red[1041511]: 10 Oct 10:20:09 - [warn] [modbus-flex-server:Modbus Slave] Error: read ECONNRESET` and after that fails to reopen the TCP port for listening. The node seemingly displays as "active" in the status. Restarting the flow or running a full deploy reopens the port. Netstat log snippets before and after a deploy (some connections omitted since they are not related): Before: `Active Internet connections (servers and established)` `Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name` `tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -` `tcp 0 0 0.0.0.0:1880 0.0.0.0:* LISTEN 1041511/node-red` `tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -` `tcp6 0 0 :::22 :::* LISTEN -` `udp 0 0 127.0.0.53:53 0.0.0.0:* -` After: `Active Internet connections (servers and established)` `Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name` `tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -` `tcp 0 0 0.0.0.0:11502 0.0.0.0:* LISTEN 1041511/node-red` `tcp 0 0 0.0.0.0:1880 0.0.0.0:* LISTEN 1041511/node-red` `tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -` `tcp 0 0 <my-public-ip>:11502 <remote-ip>:59393 ESTABLISHED 1041511/node-red` `tcp 0 0 <my-public-ip>:11502 <remote-ip>:57889 ESTABLISHED 1041511/node-red` `tcp6 0 0 :::22 :::* LISTEN -` `udp 0 0 127.0.0.53:53 0.0.0.0:* -` Unfortunately I have yet to collect debug logs from the flex-server-node, but have started node-red now with debug enabled, and can provide more detailed logs after the next incident. ### Server Modbus-Flex-Server Node (Please attach Script to the next section) ### How can this be reproduced? Leave a flex-server node running for several days, have a disconnect happen. My flow is basically Modbus-flex-server -> Function node connected from the topmost output -> mqtt out, and debug node > [ > { > "id": "27a4e55fa804ad53", > "type": "modbus-flex-server", > "z": "76d135c2798701df", > "name": "Modbus Slave", > "logEnabled": true, > "serverAddress": "0.0.0.0", > "serverPort": "11502", > "responseDelay": "200", > "unitId": "255", > "delayUnit": "ms", > "coilsBufferSize": 20000, > "registersBufferSize": 20000, > "minAddress": 0, > "splitAddress": 10000, > "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 && addr >= node.minAddress && addr <= node.splitAddress) { \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 && addr >= node.minAddress && addr <= node.splitAddress) { \n\t\tnode.coils.writeUInt8(value, addr * node.bufferFactor); \n\t\tnode.send([{ 'type': 'coil', 'addr': addr, 'value': value, 'uintID': unitID }]);\n\t} \n}", > "funcSetRegister": "function setFlexRegister(addr, value, unitID) { \n\taddr += node.splitAddress;\n\tif (unitID === node.unitId && addr >= node.splitAddress && addr <= node.splitAddress * 2) { \n\t\tnode.registers.writeUInt16BE(value, addr * node.bufferFactor);\n\t\tnode.send([{ 'type': 'register', 'addr': addr, 'value': value, 'uintID': unitID }]);\n\t} \n}", > "showErrors": true, > "x": 360, > "y": 300, > "wires": [ > [ > "b3f2965b47f9f311", > "c220cf4595ee72db" > ], > [ > "3189d68099ae8b24" > ], > [ > "21a95a5d81532d23" > ], > [ > "73a5b51c095af43a" > ], > [ > "3ad463b20669f65d" > ] > ] > }, > { > "id": "b3f2965b47f9f311", > "type": "function", > "z": "76d135c2798701df", > "name": "parse msg for mqtt", > "func": "var payload = msg;\n\nmsg = {\n topic: \"my/mqtt/topic",\n payload: payload,\n qos: 1\n}\nreturn msg;", > "outputs": 1, > "noerr": 0, > "initialize": "", > "finalize": "", > "libs": [], > "x": 610, > "y": 280, > "wires": [ > [ > "99d962b62cb9033f", > "283ece4aa50c5f67", > "08de5eaeb2252b1c" > ] > ] > }, > { > "id": "08de5eaeb2252b1c", > "type": "debug", > "z": "76d135c2798701df", > "name": "debug 13", > "active": false, > "tosidebar": true, > "console": false, > "tostatus": false, > "complete": "true", > "targetType": "full", > "statusVal": "", > "statusType": "auto", > "x": 820, > "y": 240, > "wires": [] > } > ] ### What did you expect to happen? Should recover from a connection reset properly. ### Other Information Node-RED version: 4.0.3
关闭于 2026-01-22 3 条评论