Pulseaudio control not working in exec-node

Hi community,
this is my first thread here!
My hardware is a PI zero W + bullseye with a ugreen DABBoard (I2S) and blurtooth spekers.
The installation I use works great and using CLI commands radio is playing from the speakers.
Also setting the DABBoard active and tuning to some channel is fine using "exec"-node.
The issue comes with the command for pulseaudio I'd like to send through another "exec"-node:
arecord -D sysdefault:CARD=dabboard -c 2 -r 48000 -f S16_LE | paplay
This is the error message:
Verbindungsfehler: Verbindung verweigert
pa_context_new() fehlgeschlagen: Verbindung verweigert

Basically: connection refused...

I tried with Nodered 3 and 4, Bullseye and Bookworm all bring the same error message.
I already tried a lot of suggestions but the correct was not on the list yet :wink:
Hope to find support here, thanks.

Welcome to the forum @Bitfriemler22

What OS are you using?

Edit: Also, how did you install node red and how do you run it?

Thank you Colin.
My OS is
...
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
...

For the installation I followed the standard procedure described here: Running on Raspberry Pi : Node-RED

For my purpose NR shall automatically start at boot. So I used:
...
sudo systemctl enable nodered.service
...
But if I start NR as user 'pi' there is no issue with running the exec-node.
I suspect it has to do with certain rights (root vs user)?!

It should not be running node-red as root when you run it as a service. You can check by running whoami in an exec node. The difference is probably to do with the fact that when you run node red directly from the command line you are already running in a login shell, with all the environment etc that goes with that.

Googling suggests this might work
arecord -D sysdefault:CARD=dabboard -c 2 -r 48000 -f S16_LE | XDG_RUNTIME_DIR=/run/user/1000 paplay
but I won't be surprised if it is not that. It can be extremely difficult to solve this sort of problem.

Wow, very impressed!
whoami gave "pi"
Yor suggestion to add "XDG_..." was direct hit!
I tried this before but not with the uid but with username 'pi' which was not ideal ;-).
Solved, great, thank you very much!

Excellent.
Can you mark my previous post as the solution please?

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