BiancoRoyal / node-red-contrib-modbus

maintained by PLUS for Node-RED - https://plus4nodered.com
https://www.npmjs.com/package/node-red-contrib-modbus
BSD 3-Clause "New" or "Revised" License
295 stars 109 forks source link

"Timeout error"/"Port in use" inconsistency #486

Open archerixx opened 2 months ago

archerixx commented 2 months ago

Which node-red-contrib-modbus version are you using?

5.41

What happened?

When using any Getter node, if "Reconnect on timeout" option is enabled, I never get error about device state (if it has reached "time out" or "port in use"). In some rare cases, I get error message only once at first message that goes through Getter node and never again. This is issue because in some cases when I do not use "Reconnect on timeout", Modbus client does not reconnect with device if it was in offline state for some time.

About this other issue I am not sure if it is how it should be or just bug. When I use ModbusTCP without "Reconnect on timeout", when sending request through Getter node I only get error about states "timed out" or "port in use" once every minute, not when I do calls. For instance, if I send request every 10 seconds, I do not get error on each request but just on 6th. I find this issue because I am not sure if it will always report it every minute or sometimes faster/slower, thus not allowing me to track it correctly.

Server

Other/External server

How can this be reproduced?

Please run following flow to reproduce issue: [ { "id": "d816078320159738", "type": "tab", "label": "Flow 1", "disabled": false, "info": "", "env": [] }, { "id": "841b76e40e503abb", "type": "catch", "z": "d816078320159738", "name": "", "scope": null, "uncaught": false, "x": 300, "y": 180, "wires": [ [ "1b45614b17e2c880" ] ] }, { "id": "1b45614b17e2c880", "type": "debug", "z": "d816078320159738", "name": "errorDebug", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 450, "y": 180, "wires": [] }, { "id": "9a042b1495c96e14", "type": "function", "z": "d816078320159738", "name": "modbusConfig", "func": "msg.payload = {\n 'unitid': msg.unitId,\n 'fc': msg.fc,\n 'address': msg.address,\n 'quantity': msg.quantity,\n}\nreturn msg", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 580, "y": 120, "wires": [ [ "6838ab12dd535f80" ] ], "outputLabels": [ "passthroughOutput" ] }, { "id": "6838ab12dd535f80", "type": "modbus-flex-getter", "z": "d816078320159738", "name": "modbusGetter", "showStatusActivities": false, "showErrors": true, "showWarnings": true, "logIOActivities": false, "server": "048829a3c84a650a", "useIOFile": false, "ioFile": "", "useIOForPayload": false, "emptyMsgOnFail": false, "keepMsgProperties": true, "delayOnStart": true, "startDelayTime": "2", "x": 760, "y": 120, "wires": [ [ "fe256703696564a4" ], [] ] }, { "id": "7af2f51a89643fab", "type": "change", "z": "d816078320159738", "name": "Alarms", "rules": [ { "t": "set", "p": "metrics", "pt": "msg", "to": "[{\"name\":\"Alarms/Severity/SummaryAlarmCritical\",\"value\":null,\"type\":\"Boolean\",\"priorityId\":1},{\"name\":\"Alarms/Severity/SummaryAlarmMajor\",\"value\":null,\"type\":\"Boolean\",\"priorityId\":2},{\"name\":\"Alarms/Severity/SummaryAlarmMinor\",\"value\":null,\"type\":\"Boolean\",\"priorityId\":3},{\"name\":\"Alarms/Severity/SummaryAlarmWarning\",\"value\":null,\"type\":\"Boolean\",\"priorityId\":4}]", "tot": "json" }, { "t": "set", "p": "fc", "pt": "msg", "to": "3", "tot": "str" }, { "t": "set", "p": "address", "pt": "msg", "to": "1001", "tot": "str" }, { "t": "set", "p": "quantity", "pt": "msg", "to": "4", "tot": "str" }, { "t": "set", "p": "registerType", "pt": "msg", "to": "bits", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 420, "y": 120, "wires": [ [ "9a042b1495c96e14" ] ] }, { "id": "a27925074c39079a", "type": "inject", "z": "d816078320159738", "name": "init", "props": [ { "p": "unitId", "v": "1", "vt": "num" } ], "repeat": "20", "crontab": "", "once": true, "onceDelay": "3", "topic": "", "x": 290, "y": 120, "wires": [ [ "7af2f51a89643fab" ] ] }, { "id": "fe256703696564a4", "type": "debug", "z": "d816078320159738", "name": "modbusDebug", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 760, "y": 80, "wires": [] }, { "id": "048829a3c84a650a", "type": "modbus-client", "name": "", "clienttype": "tcp", "bufferCommands": true, "stateLogEnabled": false, "queueLogEnabled": false, "failureLogEnabled": false, "tcpHost": "localhost", "tcpPort": "502", "tcpType": "DEFAULT", "serialPort": "/dev/ttyUSB", "serialType": "RTU-BUFFERD", "serialBaudrate": "9600", "serialDatabits": "8", "serialStopbits": "1", "serialParity": "none", "serialConnectionDelay": "100", "serialAsciiResponseStartDelimiter": "0x3A", "unit_id": "1", "commandDelay": "100", "clientTimeout": "2000", "reconnectOnTimeout": true, "reconnectTimeout": "2000", "parallelUnitIdsAllowed": false, "showErrors": false, "showWarnings": false, "showLogs": false } ]

What did you expect to happen?

To get error every time request is sent through Getter node that device is either: "Unreachable", "Timed out" or "Port in use".

Other Information

No response