Can not play any audio triggerd via Node Red "EXEC"

Hello all,

I have updated my Raspi OS from Buster to Bookworm with a fresh install, and with this update, a feature in node-red has died.

The feature is quite simple. I click a button on my Node-Red Dashboard, which then triggers to play a live .mp3 file. The .mp3 file is run via mpg123 (or mplayer or mpv, same issue!).

The test flow:

[
    {
        "id": "ca64f76d9cc7d5ae",
        "type": "ui_button",
        "z": "357d40f1.45eaa",
        "name": "",
        "group": "fcacb831.881f68",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "Test Button 4 Audio",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 890,
        "y": 660,
        "wires": [
            [
                "8a0525c5b378d6ce"
            ]
        ]
    },
    {
        "id": "8a0525c5b378d6ce",
        "type": "exec",
        "z": "357d40f1.45eaa",
        "command": "mpg123 http://wdr-1live-diggi.icecast.wdr.de/wdr/1live/diggi/mp3/128/stream.mp3",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "Play Rladio Test",
        "x": 1180,
        "y": 660,
        "wires": [
            [],
            [],
            [
                "c1285ce033814488"
            ]
        ]
    },
    {
        "id": "c1285ce033814488",
        "type": "debug",
        "z": "357d40f1.45eaa",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1420,
        "y": 660,
        "wires": []
    },
    {
        "id": "fcacb831.881f68",
        "type": "ui_group",
        "name": "Radio",
        "tab": "4e926670.4a0028",
        "order": 1,
        "disp": false,
        "width": "30",
        "collapse": false,
        "className": ""
    },
    {
        "id": "4e926670.4a0028",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

Visually:

The debug error:

Now i did already some debugging and I found the issue!
Even tho the command i entered is mpg123 http://wdr-1live-diggi.icecast.wdr.de/wdr/1live/diggi/mp3/128/stream.mp3, Node-Red EXEC Node is trying to run it as "sudo" aka root?! I am guessing this because when i run the same command with sudo on my Terminal, i get the same error:

pi@raspberrypi:~/.node-red $ sudo mpg123 http://wdr-1live-diggi.icecast.wdr.de/wdr/1live/diggi/mp3/128/stream.mp3
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
Segmentation fault

So it looks like, Node-Red is trying to run this as sudo, which is breaking this player feature. the same case is with all mp3 players like mpv, mplayer, vlc, mpg123. So this isnt a player issue, than rather a node-red issue.

As info, im running my Node-Red as the pi user, and not ROOT user. So why is root the default case?!

node-red version: 4.0.2
npm version: 10.8.2

Thanks!

Assuming that you are running node-red as a service, if you stop it (node-red-stop) and start it in a command window using just the command
node-red
does it then play? If so then it is due to a difference in the environment when run as a service.

Just because you get the same error message does not mean that the cause is the same (sudo).

oh wow, this fixes it..
i could fix this by removing the system autostart as service and then do a cronjob which auto starts node-red as user?
I guess this is intended?
Thanks!

No, it just means that when running as a service it does not have access to the Jack server. This is probably due to a change in Bookworm, but I don't know how to solve it.

Aight thanks.
What do you recommend how to start node-red if i dont want to run it as service?

Ok so a cronjob doesnt work, even if the cronjob is made on user side (no sudo)...

You need to find out why the jack server is not accessible from a service. Perhaps someone on a pi forum may be able to help. I did a quick Google but nothing obvious appeared.

Yea i guess. I just would love to work around this tho... :smiley:

https://forums.raspberrypi.com/viewtopic.php?t=376439

made a post. If u have any ideas, just lmk :slight_smile: ty

It is not running as root. It is running as user pi in a service.

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