Behavior changes between running as service and with the node-red command

Hi there,
I have quite an issue there and I don't understand from where it could be !

In my flow, I have a slider to control the pulseaudio volume in command lines with exec node, and some .mp3 files played with play-sound nodes.
Everything work fine when I launch node-red with the "node-red" command, but when I start it as a service, I can't control volume, and the .mp3 files won't play.

The logs before the start of the flows are the same...

I'm on raspberry pi 3b, and Node-red 3.0.2 and Node.js 19.3.0

Any idea ?

Thanks !

Here is a debug message when I try to play .mp3 file with node-red launched as a service

"High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2, and 3.
Version 0.3.2-1 (2012/03/25). Written and copyrights by Joe Drew,
now maintained by Nanakos Chrysostomos and others.
Uses code from various people. See 'README' for more!
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
tcgetattr(): Inappropriate ioctl for device

Directory: /home/cr1/.node-red/static/Sons
Playing MPEG stream from file.mp3 ...
MPEG 1.0 layer III, 192 kbit/s, 44100 Hz joint-stereo
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
Can't find a suitable libao driver. (Is device in use?)"

I don't understand why everything works fine when I don't start node-red as a service...

Okay, first, sorry for "spamming" !

I kind of "solved" the issue, with an idea I found in another topic.
I uncommented the line "autospawn=yes" in /etc/pulse/client.conf.

But I still don't get why it works now...

I am not saying that this is the reason, but noticed you are using an unstable version. Does node-red support this version? Did it work properly using v18?

Thanks for your answer !

I think it was the same because I encoutered this issue when I installed node-red with the script for raspberry pi.
I tried to reinstall everything from zero, and I manually added nodejs, npm and node-red to see if it would be better but no !

I'm not sure what all the pieces are in your set-up, but if you expect Node-RED to control the volume on the local machine then running it as a service will present challenges: it's most likely not running with the same user ID and some of the system contexts are also different.

Thanks for your reply !

I see... But just play a .mp3 doesn't work either. I think the issue is from pulseaudio, you're probably right, maybe it's not the same user id and pulseaudio can't be called or something.

Unfortunately, my knowledge of raspian and node-red are really too limited to understand better haha

Most likely this is a user/group permissions issue. Check that the user running node-red from startup is in the correct group to be able to access the audio.

Yes. The environment when running as a service and when running from the command line are going to be different.

Thanks for your reply ! :slight_smile:

I understand better now !

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