AggregateError when using pi-gpiod

Using Node-RED 5.0.4
Installed node-red-node-pi-gpiod V0.5.1 and when attempting to control a GPIO pin it throws an error -
ECONNREFUSED localhost:8888

I am a newbie to pi, web-servers and Node-RED - where should I start trying to diagnosing the root of the problem?

You have ensured that the pigpiod service is installed and running on the pi as described in the nodes README.md?

I have created a /etc/rc.local file, inserted the line
/usr/bin/pigpiod -l

and rebooted and restarted Node-RED, but the error remains as before.
When restarting Node-RED, after the usual banner it puts out the following diagnostic -
Starting as a systemd service.
8 Aug 09:23:56 - [error] [pi-gpiod out:LED - GPIO 18] AggregateError

On running ps -a in a terminal on the Pi it reports node-red-start process is running, but not pigpiod. Should I expect it to be running?

Further reading answers my own question - pigpiod is a service not a process.
Running systemctl pigpiod status gives -
○ pigpiod.service - Daemon required to control GPIO pins via pigpio
Loaded: loaded (/lib/systemd/system/pigpiod.service; disabled; preset: enable>
Active: inactive (dead)
The command node-red-log shows the error after successfully starting flows as -
8 Aug 09:23:56 - [Error] [pi-gpiod out:LED - GPIO 18] AggregateError

So the question becomes how to investigate the more than one error thrown at that point.

Hi, @delboy,

"AggregateError" indicate multiple errors at once.
See e.g. AggregateError in JavaScript.

In order to give you an idea we need more info.

  • Type of Raspberry Pi.(1,2,3,4,5)
  • Debian(Raspberry PiOS) version
  • Is 8888 the correct port?

Regards

This tells us that pigpiod is not set to run automatically at boot, and that it is currently not running.

If you run sudo systemctl enable pigpiod, then reboot the pi, do you see a different result in node-red or with systemctl status?

I don't have direct experience with the Pi nodes because i never use the gpio pins, its too easy to kill a costly Pi with hamfisted plugging.

The hardware is -
Raspberry Pi 4 Model B Rev 1.5

The O/S is -
Raspbian GNU/Linux 12 (bookworm)

The port I am using for Node-RED is 1880 following the RNT eBook 'Smart Home with Raspberry Pi' and the Flows and User Interface appear OK.
The ebook assumed Rpi nodes were installed in the version of Node-RED being used, but they were not, so I had to get into installing them myself as described in -

This defaults to exposing the daemon on port 8888. I chose to start the service in local mode by adding the line
'/usr/bin/pigpiod -l'
in /etc/rc.local, but do not know how, or if, to change the default from 8888 (to 1880?) now the pigpiod nodes are installed.

I suspect the cause of my problem was this....however -

Following guidance to enable the pigpiod daemon from the command line, the Node-RED Dashboard is now working, using the pigpio nodes to switch an LED on and off at pin18. Thanks jbudd!

My only remaining concern is the code is using port 8888 by default which the documentation flags as a security issue. Unless you can offer any further guidance on how to handle this I will close this topic and research further/raise a new one for it. Thanks all!

/etc/rc.local is one way to start a daemon process at boot, systemd (sudo systemctl enable pigpiod) is another (better) way.

You do not need both!

I suggest you find which one is successfully starting pigpiod for you and get rid of the other.

I had a look on my Pi zero 2 W, which has RPiOS Trixie Lite, and pigpiod was neither installed nor available via the normal apt update, apt install method.

I have tried installing it by downloading and compiling it, but this did not give me a systemd script, and the manually created one did not work.

Perhaps this complexity is why the page on flows.nodered.org recommends starting it via /etc/rc.local, rather than via systemd, the way Node-red itself can be automated.

Maybe @dceejay can comment on this?

This is the default port for gpiod and is fine to leave as-is - (indeed do NOT change it to 1880 or it will clash with Node-RED itself). However by default it is listening for a TCP connection from anywhere to control it - so any device on your network that know how to talk "gpio" will be able to control the daemon. Usually in an isolated home environment this is "probably" safe... but... so you can either use -l to only allow connections from localhost/ 127.0.0.1 - ie Node-RED must be running on the same machine (and not in a container), or you can use -n w.x.y.z to only allow connections from machine ip address w.x.y.z .