node-red/node-red-nodes

Serial port connection error after deploy with Node.js v20.5.1 and node-red-node-serialport 1.0.4.

Webastian opened this issue · 5 comments

Current Behavior

I am using Node-Red v3.0.2, Node.js v20.5.1 and node-red-node-serialport 1.0.4.

When I start Node-Red the connection works fine. As soon as I deploy Node-Red it tries to re-establish the serial connection. But this fails on every deploy because the port is supposedly not available. When I restart Node Red everything works as it should. It seems that Node Red is blocking the connection and cannot re-establish it.

There is no problem with Node.js v18.17.1

Welcome to Node-RED
===================

14 Aug 14:05:39 - [info] Node-RED version: v3.0.2
14 Aug 14:05:39 - [info] Node.js version: v20.5.1
14 Aug 14:05:39 - [info] Linux 5.15.0-78-generic x64 LE
14 Aug 14:05:39 - [info] Loading palette nodes
14 Aug 14:05:40 - [info] Dashboard version 3.5.0 started at /ui
14 Aug 14:05:40 - [info] Settings file : /home/app/.node-red/settings.js
14 Aug 14:05:40 - [info] Context store : 'default' [module=memory]
14 Aug 14:05:40 - [info] User directory : /home/app/.node-red
14 Aug 14:05:40 - [info] Projects directory: /home/app/.node-red/projects
14 Aug 14:05:40 - [info] Server now running at http://127.0.0.1:1880/admin/
14 Aug 14:05:40 - [info] Active project : Meilhaus_Steuerung
14 Aug 14:05:40 - [info] Flows file : /home/app/.node-red/projects/Meilhaus_Steuerung/flows.json
14 Aug 14:05:40 - [warn] Using unencrypted credentials
14 Aug 14:05:40 - [info] Starting flows
14 Aug 14:05:40 - [info] Started flows
14 Aug 14:05:40 - [info] [serialconfig:f1697cd44ae12613] serial port /dev/ttyUSB0 opened at 9600 baud 8N1
14 Aug 14:06:01 - [info] Stopping flows
14 Aug 14:06:01 - [info] serial port /dev/ttyUSB0 closed
14 Aug 14:06:01 - [info] Stopped flows
14 Aug 14:06:01 - [info] Updated flows
14 Aug 14:06:01 - [info] Starting flows
14 Aug 14:06:01 - [info] Started flows
14 Aug 14:06:01 - [error] [serialconfig:f1697cd44ae12613] serial port /dev/ttyUSB0 error: Error: Error Resource temporarily unavailable Cannot lock port
^C14 Aug 14:06:11 - [info] Stopping flows
14 Aug 14:06:11 - [info] serial port /dev/ttyUSB0 closed
14 Aug 14:06:11 - [info] Stopped flows
app@evndlegkk:~$ node-red (RESTART)
14 Aug 14:06:14 - [info]

Welcome to Node-RED
===================

14 Aug 14:06:14 - [info] Node-RED version: v3.0.2
14 Aug 14:06:14 - [info] Node.js version: v20.5.1
14 Aug 14:06:14 - [info] Linux 5.15.0-78-generic x64 LE
14 Aug 14:06:15 - [info] Loading palette nodes
14 Aug 14:06:15 - [info] Dashboard version 3.5.0 started at /ui
14 Aug 14:06:15 - [info] Settings file : /home/app/.node-red/settings.js
14 Aug 14:06:15 - [info] Context store : 'default' [module=memory]
14 Aug 14:06:15 - [info] User directory : /home/app/.node-red
14 Aug 14:06:15 - [info] Projects directory: /home/app/.node-red/projects
14 Aug 14:06:15 - [info] Server now running at http://127.0.0.1:1880/admin/
14 Aug 14:06:15 - [info] Active project : Meilhaus_Steuerung
14 Aug 14:06:15 - [info] Flows file : /home/app/.node-red/projects/Meilhaus_Steuerung/flows.json
14 Aug 14:06:15 - [warn] Using unencrypted credentials
14 Aug 14:06:15 - [info] Starting flows
14 Aug 14:06:15 - [info] Started flows
14 Aug 14:06:15 - [info] [serialconfig:f1697cd44ae12613] serial port /dev/ttyUSB0 opened at 9600 baud 8N1

Expected Behavior

Serial port connection should reconnect after deploy

Steps To Reproduce

Serial port connection error after every deploy.

Example flow

[
{
"id": "1046d4a669ac52fe",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "59620294acb0c6d2",
"type": "inject",
"z": "1046d4a669ac52fe",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "#2",
"payloadType": "str",
"x": 270,
"y": 220,
"wires": [
[
"8354e952e9216721"
]
]
},
{
"id": "8354e952e9216721",
"type": "serial request",
"z": "1046d4a669ac52fe",
"name": "",
"serial": "f1697cd44ae12613",
"x": 450,
"y": 220,
"wires": [
[
"b2ac3d2d4a2b3c07"
]
]
},
{
"id": "b2ac3d2d4a2b3c07",
"type": "debug",
"z": "1046d4a669ac52fe",
"name": "debug 6",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 220,
"wires": []
},
{
"id": "f1697cd44ae12613",
"type": "serial-port",
"serialport": "/dev/ttyUSB0",
"serialbaud": "9600",
"databits": "8",
"parity": "none",
"stopbits": "1",
"waitfor": "",
"dtr": "none",
"rts": "none",
"cts": "none",
"dsr": "none",
"newline": "\r",
"bin": "false",
"out": "char",
"addchar": "\r",
"responsetimeout": "1000"
}
]

Environment

  • Node-RED version: 3.0.2
  • Node.js version: 20.5.1
  • npm version: 9.6.7
  • Platform/OS: Ubuntu - Linux 5.15.0-78-generic x64 LE*
  • Browser: Chrome 115.0.5790.111

Moving this issue over to the nodes repository where the serial node lives.

What deployment mode are you using? As a work around can I suggest you set deploy to "Only changed nodes" which should not restart the serial node unless edits have been made.

node-red-node-serial-port is based on the serialport node, that node pushed changes this week which have broken running on Docker (alpine) with the pre-built binaries and it looks like there may have been other changes.

I have an open issue for the binary problem, but we may have to pin to a back level serialport version for a while.

i have had the same problem.after each deploy doesnt matter just changed nodes or full deploy com port was become unreachable.Sometimes for 30-40 seconds sometimes until reboot raspberry p. i donwgraded serialport to 1.0.3 and problem solved.there is something wrong with version 1.0.4
cd ~/node-red
or
cd /home/pi/.node-red
npm i node-red-node-serialport@1.0.3
then

node-red-stop
node-red-start

There are several newer versions of the underlying serialport npm library (up to v12.0.1 as I type) - but that pre-reqs nodejs 16 - so until we release Node-RED 4 and drop v14 support we can't really move to that.

should be fixed by version 2.0.0 and later