Weird Httpstatic configuration in Setting.js in NR windows 11

Hi Colin,
thank you very much for your and Steve's support in this tricky situation.

No, trying to open the image from the browser with http://IP:1880/schemaloex.png I get this error:

Cannot GET /schemaloex.png

This happens both with a browser on the windows local machine where NR runs and my Mac remote machine)

BTW the browser I use is Chrome. I also tried Edge on Windows, but same result.

The only way I can get the image is bypassing node-red and getting directly from the browser with:

C:/domotica/schemaloex.png

Another way you can see the image inside NR is getting it with a file node, encoding it with base64 node and passing the encoded stream to the template node with this code :

<img width="100%" height="100%" alt="Image not found" src="data:image/png;base64,{{msg.payload}}" />

Can you confirm that with your setup node-red 3.2 would be able to get the image using localhost:1880/schemaloex.png on a windows 11 pro pc with Chrome browser?

If so I'm asking what happened to my node-red-dashboard-template installation?

What if using "Manage Palette" I delete the complete dashboard node and reinstall it? I understand that the template node alone is not manageable by the palette manager.

I'll ask Steve if he can send me a sample flow with his template node. I will import it and see if any difference

Can you show us the startup log for node-red when it is started by whatever means it is normally started?

Hi Steve,
this is the Chrome dev tool windws if I inspect the not found image:

Apparently I have no clue why the image is not found. Frankly I do not know what to look for.

I also replied to Colin who asked me if localhost:1880/schemaloex.png would show the image, but it can't, I get the error:

Cannot GET /schemaloex

It looks like NR has permission problem with the resources on the same machine where it runs or there is some problems in the dashboard node.
BTW can you send me your test flow with the template so I can import it and see if any difference?

I'm getting to the conclusion that I will end up reinstalling the whole Node-red!

Or httpstatic is not setup correctly, hence me asking to see the node red startup log when it is started by whatever means it is normally started.

Open the network tab (like I highlighted in the screen shot) & refresh the page

Hi Colin,
I enclose the startup screenshot starting NR with cmd node-red after having closed it with task manager

As you can see we have a cryptic error EADDRINUSE 0.0.0.0:1880 whereas the ip of my machine is 192.168.178.59.

Hi Steve,
Sorry I missed your advice. Here is the network tab opened. Do note that all images from the complete template on the left (the one I imported from the Raspberry Pi machine) are missing as well.

As I said previously, that means you have not stopped node red, or it has restarted itself. How is node red normally started?

The point being, in case you didn't realise, that when you start node-red using the node-red command it uses that settings.js and http static is setup, but which settings.js is it using when it starts normally, and ends up with SYSTEM as the user?

Hi Colin,
you are right, the problem is that there are 8 settings.js files in my machine after a search, but only two with size 23 kB looks good for our purposes.

For sure initially I edited the file inside C:|Users\rober.node-red, but apparently this is not the file used by node-red when starts up. So I edited the file in C:\Users\rober\Appdata\Roaming\npm\node_modules and restarted the machine, but still the images are not visible.

NR starts up as a service on machine restart using NSSM following the instruction of NSSM web site regarding node red.

It looks like NR uses another one settings.js since its Httpstatic is not yet set, but I can I discover it?

Give us a link to how you installed it

[Edit] I mean how you configured it to run on boot.

You should probably have mentioned this much earlier.

So you likely have nssm setup with mostly default settings. And by default nssm uses the system account. When node-red runs under a different account it uses that users environment and "home" directory.

There are 2 ways to proceed...

  1. Edit the nssm setup & get it to write stdout and stderr logs to files so that you can read the start up log - that will tell you everything you need to know.
  2. Alternatively, you could change the "runas" settings to use your own account then it would use the settings file you have been modifying.

Hi Steve and Colin,
the decision to use NSSM to start NR at startup has been the worst I could take!
I followed the instructions found on this forum

https://discourse.nodered.org/t/run-on-windows-as-service/13569/2

but I was not aware that the Node-red started as a service (owned by SYSTEM) is a completely different story than starting NR from a current user with node-red command!
For instance it has been proved that NR as a service has no way to get the local images using the template node even if you edit httpStatic parameter in

"C:\Users\rober\AppData\Roaming\npm\node_modules\node-red\settings.js"

Probably a more experienced user knows how to do it, but not an average end user as me. I preferred to deactivate the NSSm script and, for the time being, to start NR uniquely using its command from the terminal. At a later stage I will put it under task scheduler, but this will be trivial.

The downside of the new way of opening NR is that now I (apparently) lost my previous work, flows and added nodes! The new flow is completely empty!
I expected to find a second flows.json in Appdata, but, no way, the file "flows.json" exists in the CurrentUser.node-red\ folder only!

The only way to recover my work has been to restart NR as a service, export all flows on a file, closing the service, opening NR as a current user and importing from file. Then patiently I had to reinstall all missing nodes!

So the support case can be closed. Now I finally see all images from template node!

Thanks again for your help and patience.
BTW can you please suggest me which file/s should I backup to protect all my new flows and added nodes so to easily restore my NR setup in case of a disaster?

If I am allowed to give an advice I will somehow emphasize on the official docs that NR in a windows machine should be operated from the terminal with its command "node-red" and not as a service created by NSSM unless you are a windows naughty programmer and can tweak it to behave like NR opened by the current user. Hopefully this hard learnt lesson will be useful to other NR users on windows machines!

I personally believe that is out of scope - NSSM is perfectly viable (in the right hands).

You issue was being unaware that NSSM chose by default to run under the system account. It does this for very good reason.

Like any user, the system account has a "home" directory.
The reason you dont find any flow files using a regular search (from your own user account) is because the system users files are protected from other users (again - for good reason)
image

If you want to find your old flows etc, you should have enabled the logging in NSSM...

... then you would have seen something like ...

30 Oct 15:49:29 - [info] Flows file     : C:\WINDOWS\ServiceProfiles\LocalService\blah\blah\flows.json

Or a quick search on the internet for Where can I find system data stored by a Windows Service would have revealed the location %systemroot%\ServiceProfiles

The point is, you seem like (no offence) a "regular" user (not a power user / windows expert) and the NR docs are not really a place to teach or preach - it is not an easy balance.

However, we would definitely consider a PR to the docs around this area.


Moving forward...

My recommendation would be...

  1. move your node-red userDir to c:\something
    • make sure the service account AND your user account have read-write access
  2. set NSSM to run node-red -p 1880 -u c:/something
  3. set the NSSM "log" tab up to output STDOUT and STDERR to write to log files in c:/something and enable log rotation
  4. Enable NSSM

NOTE: c:\something should really be something like c:\node-red-1880 - the above was for illustration purposes

Here are a few of threads that should help...

Steve,
you are right I'm not a power user and I used NSSM without studying its intricacies, particularly it was my fault not having activated the error logs. I considered it a simple utility for an automatic NR startup, but it's not, it changes the way NR works on the user machine.

In any case it's a fact that running NR as a service in windows platform using the default NSSM installation NR has no way to use local user images thru the template node! My previous experience with NR was on a linux based Rasberry Pi4 and I didn't have so many difficulties and caveats.

In my previous post I asked which are the user critical files to backup in case of a disaster so to be able to recover all your setup simply reinstalling node-red and restoring these files.

If you want a simpler way of running Node-RED robustly with the benefits of auto-restart, log management, etc, I would recommend using PM2 and starting that using Task Scheduler.

One thing to note is that if you want to run node-red before you have logged in with your user account, you will have to give scheduler your password. A better alternative is to allow PM2 to start under the SYSTEM account now that you know a bit more about how it works :slight_smile:

Alternatively, consider setting up another local user that does not have local admin rights and run PM2/node-red under that. That could be a bit more complex if you need access to specific shared local resources but at least avoids a messed up flow (or malware compromise) messing up your main account.

PM2 does have some overheads as it is itself a node.js application. But it is quite powerful. For example, you can configure it to "watch" key files/folders and automatically restart node-red. I use this feature to make development of node-red nodes a lot nicer.

Or of course you could avoid all this hassle by switching to Ubuntu and using our recommended install script which will set it all up for you.

You can do that one Windows too using WSL :slight_smile:

I even think that systemd is coming to WSL soon.

So perhaps eventually Windows will become just a wrapper round Linux :slight_smile:

Nah, Linux will become a component of Windows :crazy_face: