node-red-contrib-modbus: Modbus TCP: "PortNotOpenError: Port Not Open"

I’m submitting a …

Problem

  • (x) unexpected behavior

Current behavior

My device doesn’t maintain permanent TCP connection and close after 1.5 second or so. Single FC 3 request rise the list of errors: TypeError: Cannot read property 'getMachineState' of undefined PortNotOpenError: Port Not Open FSM Reset On State [object Object] Client -> try to reconnect by init in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 Client -> try to reconnect by init in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 FSM Reset On State [object Object] Client -> try to reconnect by init in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 Client -> reconnect in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 Client -> reconnect in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 Client -> reconnect in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1

and log from console: 5 Dec 09:08:04 - [error] [modbus-flex-getter:Shtyl] TypeError: Cannot read property 'getMachineState' of undefined at Object._inputCallback (/data/node_modules/node-red-contrib-modbus/modbus/maps/modbus-flex-getter.js:123:61) at Object.Node._emitInput (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:199:18) at Immediate._onImmediate (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:179:33) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) 5 Dec 09:08:04 - [error] [modbus-flex-getter:Shtyl] PortNotOpenError: Port Not Open at ModbusRTU.writeFC4 (/data/node_modules/modbus-serial/index.js:501:24) at ModbusRTU.writeFC3 (/data/node_modules/modbus-serial/index.js:487:10) at /data/node_modules/modbus-serial/apis/promise.js:48:31 at new Promise (<anonymous>) at ModbusRTU.readHoldingRegisters (/data/node_modules/modbus-serial/apis/promise.js:39:27) at Object.noneCommandSent [as callModbus] (/data/node_modules/node-red-contrib-modbus/modbus/maps/modbus-client.js:550:7) at Object.sequentialDequeueCommand (/data/node_modules/node-red-contrib-modbus/modbus/maps/modbus-client.js:140:13) at Timeout.r.dequeueCommand [as _onTimeout] (/data/node_modules/node-red-contrib-modbus/modbus/maps/modbus-client.js:172:14) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10) 5 Dec 09:08:04 - [warn] [modbus-flex-getter:Shtyl] FSM Reset On State [object Object] 5 Dec 09:08:04 - [warn] [modbus-client:Shtyl-dacha] Client -> try to reconnect by init in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 5 Dec 09:08:04 - [warn] [modbus-flex-getter:Shtyl] FSM Reset On State [object Object] 5 Dec 09:08:04 - [warn] [modbus-client:Shtyl-dacha] Client -> try to reconnect by init in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 5 Dec 09:08:05 - [warn] [modbus-client:Shtyl-dacha] Client -> reconnect in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 5 Dec 09:08:05 - [warn] [modbus-client:Shtyl-dacha] Client -> reconnect in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1 5 Dec 09:08:05 - [warn] [modbus-client:Shtyl-dacha] Client -> reconnect in 100 ms TCP@192.168.77.137:502 default Unit-Id: 1

no response for request, request is lost. The only workaround, constantly send requests, in that case only first one is lost.

Expected behavior

Process a request. If port is closed, should open connection and process a request.

Minimal reproduction of the problem with instructions

  1. Create simple flow with Getter or FlexGetter node with TCP connection.
  2. Device should close connection.
  3. Send FC 3 request in result list of errors and no response.

Your Environment

Please tell us about your environment:

  • (x) I am using just the Node-RED package and got modbus-serial package installed with it

  • ( ) I have installed modbus-serial package global from source (using git clone)

  • ( ) I have installed modbus-serial as a global package (using npm i -g)

  • node-red-contrib-modbus version: 5.1.0

  • Node: (min. 6.x) node --version = v10.17.0 Node-RED 1.0.3 docker on raspberry PI

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, some devices will close the Port if the communication is to slow. Why should the queue work with a delay per message of 1 sec. ? Please, check the Modbus Specs or the information of the responding Modbus device in those cases.