More audio problems using exec node

Hi
I've raised this issue before and Colin very kindly found a resolution. I've now completely rebuilt my PI4 around "Bookworm" and problem has arisen again. Using ssh to the PI if I enter:
mpg123 /home/pi/recordings/testFile.mp3 ... it plays without error.

If I run same command in an node red exec I get this:
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.31.2; written and copyright by Michael Hipp and others
free software (LGPL) without any warranty but with best wishes
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

I've tried the old solution "DISPLAY=:1 mpg123 /home/pi/recordings/testFile.mp3" and it still fails.
Similar to before if I node-red-stop and then node-red, then it works.

Any help please...

Further to this:
node-red-contrib-play-audio-file also won't play files unless I stop node red and start it again using "node-red" instead of "node-red-start"

I don't know what is the difference between the 2 methods of starting node red. Is it possible to auto start it in the mode "node-red"

Open a CLI to the Pi running NR and then run this command:
cat /lib/systemd/system/nodered.service
look at the first couple lines and find the [Service] section. Is the user named there the same user name you are using when you use 'node-red' to start?

If they are different run groups xx (replacing 'xx' with the user id) and compare the output of the two.
Are there any differences? (like one has sudo and the other doesn't)

Both scenarios seem to be identical:

systemd service file to start Node-RED

[Unit]
Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=Redirecting…

[Service]
Type=simple

Run as normal pi user - change to the user name you wish to run Node-RED as

User=pi
Group=pi
WorkingDirectory=/home/pi

Environment="NODE_OPTIONS=--max_old_space_size=512"

define an optional environment file in Node-RED's user directory to set custom variables externally

EnvironmentFile=-/home/pi/.node-red/EnvironmentFile

uncomment and edit next line if you need an http proxy

#Environment="HTTP_PROXY=my.httpproxy.server.address"

uncomment the next line for a more verbose log output

#Environment="NODE_RED_OPTIONS=-v"

uncomment next line if you need to wait for time sync before starting

#ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-timesyncd.* Synchronized to time server"'

ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS

Use SIGINT to stop

KillSignal=SIGINT

Auto restart on crash

Restart=on-failure
RestartSec=20

Tag things in the log

SyslogIdentifier=Node-RED
#StandardOutput=syslog

[Install]
WantedBy=multi-user.target

There are multiple differences. For a start, when you run node-red the command is associated with a display. The environment variables (PATH etc) are also going to be different. Didn't we go over all this the first time round?

Have you tried DISPLAY=:0 instead of :1?

Colin
Yes I have referred back to our previous posts. On that occasion DISPLAY=:0 sorted it.
Yes I have tried DISPLAY=:1 to no avail.
It seems strange (to me) that the well tested "node-red-contrib-play-audio-file" also won't play. Am I the only one having this issue? This is a completely fresh Bookworm os.

Is the clue to why your the only one having problems
Its a new Pi OS and your probably the only person trying to do this

Part of the issue may be that audio and the display system changed with bookworm. Prior to this it used ASLA and X1, with Bookworm it uses PulseAudio an Wayland.

Probably explains why I cannot seem to find anything that will play mp3 files from the Bookworm PI.
I've spent a lot of time on this so probably best to go back to Bullseye for now.
Thanks for your help.

Actually before I give up I would be very appreciative of anyone who can tell me how to play locally stored mp3 files out of the headphone socket via Node red Bookworm.

Hi
Bookworm was released 7 months ago and I, like lots of others was keen to not let my install get stale. I would be surprised if I am the only one trying to play audio files from my PI. Is it the case that most people just stick with their older working OS when it is stable. Was I wrong to upgrade?
thanks.

Sorry _ I thought it only came out on the Pi in October - didn't realise it'd been out that long

I meant your probably the only one trying to do it using NR using bookworm

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