Audio problems using exec node

I have been using an exec mode in node red to play mp3 files for quite some time and now it has stopped working.
I can't find any error messages anywhere.
If I run this line in a terminal window it works

mpg123 /home/pi/recordings/testFile.mp3

If I run it in an node red exec I get nothing but exec output shows success with { code 0 }
Any help please...
thanks

What did you change that stopped it working?

I can't think of any recent changes.

  1. does the file actually exist?
  2. how is the exec node configured? (export it and paste to a reply)
  3. add a catch node connected to a debug node (set to display the complete msg object) and run the flow...anything show up?

Yes file does exist as I can play it directly in terminal.
Debug shows { code 0 } which I think means success.

[{"id":"1ad327d469e11e2f","type":"exec","z":"5081acab.0242b4","command":"mpg123","addpay":"","append":"/home/pi/recordings/blue_bin_gets_collected_on_friday.mp3","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"play sounds","x":1350,"y":960,"wires":[["80ea5a17b0eaefe5"],["80ea5a17b0eaefe5"],["80ea5a17b0eaefe5"]]},{"id":"cb737bf2b66b48c6","type":"inject","z":"5081acab.0242b4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"/home/pi/recordings/blue_bin_gets_collected_on_friday.mp3","payloadType":"str","x":1190,"y":960,"wires":[["1ad327d469e11e2f"]]},{"id":"80ea5a17b0eaefe5","type":"debug","z":"5081acab.0242b4","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1560,"y":960,"wires":[]}]

Does it play if you run node red in a terminal window using
node-red
rather than starting using the systemd script on boot or with node-red-start?

So I stop node red using
node-red-stop
then start using using
node-red
Yes that works.... but why?

Are you sure it has ever worked when running using the systemd script?

Are you sure there are no errors reported in any of the outputs of the exec node when connected to debug nodes set to Output Complete Message?

I have been using this exec node to play mp3 files for years.

The debug output is
msg.payload : string[405]

"High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3↵→version 1.25.10; written and copyright by Michael Hipp and others↵→free software (LGPL) without any warranty but with best wishes↵↵Directory: /home/pi/recordings/↵Playing MPEG stream 1 of 1: blue_bin_gets_collected_on_friday.mp3 ...↵↵MPEG 2.0 L III cbr48 22050 mono↵↵↵[0:02] Decoding of blue_bin_gets_collected_on_friday.mp3 finished.↵"

19/04/2023, 12:13:41node: debug 2msg.payload : Object

{ code: 0 }

node red log shows nothing

Please stop NR and start it again and copy the output thru where it says
19 Apr 06:25:57 - [info] Started flows
and paste the results here.

Just wondering if the user you installed NR under is the same when running when using node-red-start.

pi@atticPI:~ $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://10.0.0.50:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
19 Apr 12:30:38 - [info]
Welcome to Node-RED
===================
19 Apr 12:30:38 - [info] Node-RED version: v2.0.5
19 Apr 12:30:38 - [info] Node.js  version: v15.14.0
19 Apr 12:30:38 - [info] Linux 5.10.103-v7l+ arm LE
19 Apr 12:30:39 - [info] Loading palette nodes
19 Apr 12:30:43 - [info] Worldmap version 2.33.0
19 Apr 12:30:43 - [info] Dashboard version 3.4.0 started at /ui
19 Apr 12:30:43 - [warn] ------------------------------------------------------
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-account] 'alexa-remote-account' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-init] 'alexa-remote-init' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-event] 'alexa-remote-event' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-smarthome] 'alexa-remote-smarthome' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-routine] 'alexa-remote-routine' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-echo] 'alexa-remote-echo' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-other] 'alexa-remote-other' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] [node-red-contrib-alexa-remote2/alexa-remote-list] 'alexa-remote-list' already registered by module node-red-contrib-alexa-cakebaked
19 Apr 12:30:43 - [warn] ------------------------------------------------------
19 Apr 12:30:43 - [info] Settings file  : /home/pi/.node-red/settings.js
19 Apr 12:30:43 - [info] HTTP Static    : /home/pi/JMpics > /
19 Apr 12:30:43 - [info] Context store  : 'default' [module=localfilesystem]
19 Apr 12:30:44 - [info] User directory : /home/pi/.node-red
19 Apr 12:30:44 - [warn] Projects disabled : editorTheme.projects.enabled=false
19 Apr 12:30:44 - [info] Flows file     : /home/pi/.node-red/flows.json
19 Apr 12:30:44 - [info] Server now running at http://127.0.0.1:1880/
19 Apr 12:30:44 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
19 Apr 12:30:44 - [info] Starting flows
19 Apr 12:30:44 - [info] [tcp out:telnet] connecting to localhost:7072
19 Apr 12:30:44 - [info] [tcp out:telnet] connecting to localhost:7072
19 Apr 12:30:44 - [info] [worldmap:ea01c54a6765424c] started at /worldmap
19 Apr 12:30:44 - [info] Started flows
19 Apr 12:30:44 - [info] [aedes broker:AEDES MQTT] Binding aedes mqtt server on port: 1884
19 Apr 12:30:44 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok
19 Apr 12:30:44 - [info] [serialconfig:9d5f7edf.fec6f] serial port /dev/ttyUSB0 opened at 9600 baud 8N1
19 Apr 12:30:44 - [info] [mqtt-broker:THIS PI] Connected to broker: mqtt://127.0.0.1:1883
19 Apr 12:30:44 - [info] [tcp out:telnet] connected to localhost:7072
19 Apr 12:30:44 - [info] [tcp out:telnet] connected to localhost:7072
19 Apr 12:30:44 - [info] [mqtt-broker:OTHER PI] Connected to broker: mqtt://10.0.0.51:1883
19 Apr 12:30:45 - [info] [mqtt-broker:cloud-MQTT] Connected to broker: mqtt://m20.cloudmqtt.com:12213
19 Apr 12:30:45 - [info] [mqtt-broker:Beebotte] Connected to broker: mqtt://mqtt.beebotte.com:1883


@Colin, in looking at this thread, I tried running NR with node-red and node-red-start. What is interesting is that with node-red-start if I use HTOP to look at the process it shows:
node --max_old_space_size=256 /usr/lib/node_modules/node-red/bin/../red.js

while using 'node-red' to start it shows this:
node /usr/bin/node-red

think there could be a issue here? Also it's running node v15.14.0 -- another possible issue??

I don't understand any of that... is there a solution?

If that is all you see in the debug nodes then you have not got them set to Output Complete Message, however it appears from what you have shown that the command thinks it completed ok.

That could be an issue. That is an unsupported version. Only LTS versions are supported (so 14, 16 and 18). I doubt if that is the problem here though, I can't see how it could affect the spawned command.

I don't know mpg123, does it show a gui display when you run it? You could try using the command
DISPLAY=:0 mpg123 /home/pi/...
or
DISPLAY=:1 mpg123 /home/pi/...

Another question, when you run it in a terminal or using the node-red command, are you doing that actually on the pi, or are you connected to the pi using ssh? If not using ssh then try that and see if it still works.

Ok I'm running headless so...
if I vnc into the pi and use its own native terminal it works.
When I use ssh from my PC it does not. ???

@Colin I was starting NR via SSH

@muggins John, I just installed your flow on a Pi and started NR both ways. The flow plays an mp3 in both cases. That said I used a
Pi 3 Model B Rev 1.2 running BUSTER
Node-red v3.0.2
node.js v16.19.1

  1. Are your speakers plugged into the Pi? (Just have to check)
  2. what model Pi and what OS are you running? (using lsb_release -c will give you the OS and cat /proc/device-tree/model will give the model)

pi@atticPI:~ $ lsb_release -c
Codename: buster
pi@atticPI:~ $ cat /proc/device-tree/model
Raspberry Pi 4 Model B Rev 1.2pi@atticPI:~ $
sound output is via audio jack to an amp+speakers in our kitchen.
It does all sorts including bin day reminders and telling my wife to water the plants.
It has been working for ages and has just stopped. The only thing I can think of is an upgrade of Dashboard

It isn't to do with node-red. The reason it doesn't run from an ssh shell will be the same as the reason it doesn't run from within node-red. Did you try with the DISPLAY env var setting in the command? Though I don't hold out much hope.

Did you update any OS packages recently?

Hi Colin
There seems to be some confusion...
It runs fine from remote ssh shell
It runs fine from native terminal on RPI.
It does not run from exec mode.
thanks
John