Running Node-RED on multiple instances but with separate set of flow

Hello everyone, sorry that I have to make another post again. So currently I've worked on making a interface where user have to login through dashboard and I've set a default persistent content on my main port.

The question is, if multiple user tried connected to the same port i.e. 1880, it'll keep overwriting each other's data on the flow in context data. From what I've read (Node red multiple instances), running Node-RED on multiple instances would work.

After importing the exact flow into a different port i.e. 1881, the dashboard shows nothing and I can't bring up the side menu to see what other groups do I have in that.

Are there any other workarounds that I can try? Thanks in advance

If you follow the below you will have separate instances with separate flows and separate dashboards etc...

Yea I did the exact thing, but the dashboard is not showing the content of the widget as shown in the original post.

Sorry maybe I should also mentioned that I'm running this on windows.

Open your browser dev tools and look at the console to see if you have any errors.

Those instructions miss something off as well. When creating the new folders, you then should copy across some files from your original if you are wanting to use the same flow. You will also need to run npm install in each folder after you have copied the basic files unless you have copied over the node_modules folder (which is best avoided as it takes a long time to copy).

Personally, I would have at least 5 instances. Keeping at least one as a master/test bed and creating a script that copies the flows (and possibly creds) and the package.json to each of the user instance folders. The script would need to adjust the starting port of course.

For the master, I would actually have maybe a 6th instance that uses a local install of Node-RED (see my alternate installer repo for an example). That gives you the ability to test your flows on a different version of Node-RED.

Those instructions miss something off as well. When creating the new folders, you then should copy across some files from your original if you are wanting to use the same flow. You will also need to run npm install in each folder after you have copied the basic files unless you have copied over the node_modules folder (which is best avoided as it takes a long time to copy).

I'll take a look on that, how do i run npm install to that specific folder tho?

After trying to copy and paste the original folder into the new instances. It still has the same problem with the dashboard. The browser console log shows this:

The cmd shows something like this as well

C:\Users\weeseong.hew>node-red -p 1881 -u c:/node-red-1881
29 Jul 17:26:00 - [info]

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

29 Jul 17:26:00 - [info] Node-RED version: v2.0.2
29 Jul 17:26:00 - [info] Node.js  version: v12.20.2
29 Jul 17:26:00 - [info] Windows_NT 10.0.19042 x64 LE
29 Jul 17:26:02 - [info] Loading palette nodes
29 Jul 17:26:06 - [info] Dashboard version 2.30.0 started at /ui
29 Jul 17:26:07 - [info] Settings file  : c:\node-red-1881\settings.js
29 Jul 17:26:07 - [info] Context store  : 'default' [module=localfilesystem]
29 Jul 17:26:07 - [info] User directory : c:\node-red-1881
29 Jul 17:26:07 - [warn] Projects disabled : editorTheme.projects.enabled=false
29 Jul 17:26:07 - [warn] Flows file name not set. Generating name using hostname.
29 Jul 17:26:07 - [info] Flows file     : c:\node-red-1881\flows_ITC-NB-23.json
29 Jul 17:26:07 - [info] Server now running at http://127.0.0.1:1881/
29 Jul 17:26:07 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

29 Jul 17:26:07 - [info] +-----------------------------------------------------
29 Jul 17:26:07 - [info] | uibuilder v4.1.0 initialised
29 Jul 17:26:07 - [info] | root folder: c:\node-red-1881\uibuilder
29 Jul 17:26:07 - [info] | Using Node-RED's webserver at:
29 Jul 17:26:07 - [info] |   http://192.168.68.101:1881/ or http://localhost:1881/
29 Jul 17:26:07 - [info] | Installed packages:
29 Jul 17:26:07 - [info] |   jquery, socket.io, bootstrap-vue, vue
29 Jul 17:26:07 - [info] |   bootstrap, vue.js
29 Jul 17:26:07 - [info] +-----------------------------------------------------
29 Jul 17:26:07 - [info] Starting flows
29 Jul 17:26:07 - [info] Dashboard version 2.30.0 started at /ui
29 Jul 17:26:07 - [info] Started flows
29 Jul 17:26:08 - [red] Uncaught Exception:
29 Jul 17:26:08 - TypeError: path must be absolute or specify root to res.sendFile
    at ServerResponse.sendFile (C:\Users\weeseong.hew\AppData\Roaming\npm\node_modules\node-red\node_modules\express\lib\response.js:425:11)
    at c:\node-red-1881\node_modules\node-red-contrib-ui-media\ui_media.js:288:17
    at FSReqCallback.oncomplete (fs.js:156:23)

That error might be related to node-red 2.0.2 (there are a few fixes in newest release 2.0.4)

I would upgrade node-red before trying too many things.

If the error persists then that might be an issue with the ui-media node (or node-red http handling)

That tells me that you didn't copy the flows file. It has created a new one for you.

You need to look in your master userDir folder (the original) and see what files and folders exist. Copy everything you need over except the node_modules folder, you use npm install in each of the folders to download and install each contributed node into each folder. You can copy the folder if you like and avoid the install but it is thousands of files and will take a lot of time, especially if you try to use Windows Explorer.

1 Like

I've uninstalled ui-media node and it still has the same issue

Are you sure it is uninstalled? Have you restarted node-red?
If it is uninstalled, you will not get that error as the code will be deleted.

hmmm what I did was basically create a new folder 'node-red-1881' and copied all the files except the node_modules folder and paste it in the new folder. After that, I've launched Node-RED with the command node-red -p 1881 -u c:/node-red-1881 and install all the palettes needed. After all that it still has the same issue. Even after I've uninstalled ui_media palette.

Yea, the things run normally after restarting node-red. I might give that a try again and see if it works.

Just went and check and it show this error log on the 127.0.0.1:1881/ui now

Try editing the URL and remove everything after the /ui/.

I've updated node-red to 2.0.4 and it doesn't seem to solve that issue

Did that, it does nothing

Can you provide:

  • A directory listing of c:\node-red-1881

  • A screenshot of Editor Dashboard sidebar showing the layout tab

    image

  • The node-red log for that instance.

That last isn't the node-red log. You need the log that is shown when you start up node-red.

Ahh my bad, here's the Node-RED log

So what exactly is the problem? The Uncaught Exception problem is not there, which I thought was the main issue.