Serial port connection error after deploy

Hi guys,

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. Does anyone have a solution to this problem?

*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***

Best regards
Sebastian

Welcome to the forum @Webastian.

I don't know what is causing the issue, but if you click the dropdown arrow on the Deploy button you can tell it to only deploy modified nodes, then when you deploy it will not restart the serial port so you should not see the issue. Also it will deploy much quicker.

I notice you are using nodejs20. We don’t recommend that just yet as often packages may not be updated to be fully compatible.

Many thanks Colin, even if this is not the complete solution, it is extremely practical and brings me a bit further. And you are right. If I deploy only the changed nodes, there is no issue.

Thanks dceejay. That is a good hint. I will try to downgrade Node.js

That was the solution. Thank you very much.

Could you submit an issue please at Issues · node-red/node-red · GitHub. I expect the developers will want to fix it as nodejs 20 will be supported soon (I expect).

There it is: Serial port connection error after deploy with Node.js v20.5.1 and node-red-node-serialport 1.0.4. · Issue #1028 · node-red/node-red-nodes · GitHub

Great, thanks.

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