# Exec Node and Terminal Problem ( Alsa)

**URL:** <https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980>\
**Category:** General\
**Created:** [16 April 2020 22:27 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980 "2020-04-16T22:27:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [16 April 2020 22:27 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/1 "2020-04-16T22:27:05Z")

</div>

Hello everyone,

i try to play music with the raspberry and also play random sound effects at the same time.  
i followed this tutorial: [http://pacmans-revenge.blogspot.com/2018/08/raspberry-pi-bluetooth-speakers.html](http://pacmans-revenge.blogspot.com/2018/08/raspberry-pi-bluetooth-speakers.html)  
but it doesnt work like i want it to. while i am connected with my mobile to the raspberry and stream a song, i can run a music file from the terminal, but i can not trigger it with the same command from nodered.

 ![failure](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b852990b5cbc4a0eaece7bb9a24188a71b1c66f3.jpeg)

In the tutorial link mentioned above, u can see what my config look like.  
I just changed the /home/pi/.asoundrc to the following for a test.

```auto
pcm.!default {
        type plug
        slave.pcm "dmixer"
}

pcm.dmixer {
        type dmix
        ipc_key 1024
        slave {
                pcm "hw:1,1"
                period_time 0
                period_size 1024
                buffer_size 4096
                rate 44100
        }
        bindings {
                0 0
                1 1
        }
}

ctl.dmixer {
        type hw
        card 1
}

```

and configured the pulse audio sink and source like that

pactl load-module module-loopback source=bluez\_source.20\_DA\_22\_73\_84\_1D.a2dp\_source sink=alsa\_output.platform-snd\_aloop.0.analog-stereo

Hope anyone knows the solution... i try to find a way since 4 weeks or something ... ☹

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [18 April 2020 10:45 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/2 "2020-04-18T10:45:53Z")

</div>

okay i made a little work around ... my new strategy is to just build up an ssh connection inside nodered and send the play commands via that method. now the only problem i got is that the ssh connection does allways close after one command. anyone knows a strategy ?

iam currently useing sshpass.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 April 2020 11:02 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/3 "2020-04-18T11:02:08Z")

</div>

You can send commands one at a time using ssh using  
`ssh user@server "some_command to execute remotely with params"`  
That way you don't need to build and maintain the connection.

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [19 April 2020 14:19 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/4 "2020-04-19T14:19:35Z")

</div>

Hi, thanks for your help. Now it open the ssh connection without authentification via passwort and uses instead a key file.

My problem is, that everytime it open the connection, there is about 500ms delay. if i want to play an audiosample just in time, this is a problem.

so i need to have an connected ssh tunnel which, after first connection, can be used to pump more commands to that established connection... any idea how to do that in nodered ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 April 2020 15:06 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/5 "2020-04-19T15:06:29Z")

</div>

You could use mqtts to send the commands instead.

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [19 April 2020 15:21 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/6 "2020-04-19T15:21:38Z")

</div>

i can play sound just via and established ssh connection, mqtt wont help me in that case i think.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 April 2020 15:31 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/7 "2020-04-19T15:31:15Z")

</div>

It means you don't need an ssh tunnel. Much simpler.

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [19 April 2020 15:32 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/8 "2020-04-19T15:32:18Z")

</div>

how can i use my "play" function via mqtt ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 April 2020 16:22 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/9 "2020-04-19T16:22:32Z")

</div>

Pick it up in node-red at the other end and run the command in an exec node.

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [19 April 2020 17:17 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/10 "2020-04-19T17:17:33Z")

</div>

but that is just another way to pump a command to the exec node. the problem still is, that the command "play /dedo.wav" pumped in the exec node doesnt work. i have to use a terminal or a ssh connection to be able to play a soundfile.  
i still got the problem which i mentioned in the picture i postet at my thread start.  
the ssh connection was just a work around.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 April 2020 19:13 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/11 "2020-04-19T19:13:44Z")

</div>

Oh, sorry, I thought you were using a tunnel to get to another machine.  
Can you give us a translation of the error message you showed earlier please.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [19 April 2020 19:23 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/12 "2020-04-19T19:23:41Z")

</div>

If you are playing the music on the Pi and have the speakers attached to it, have you tried using node-red-contrib-playsound? Not sure if it will work with bluetooth speakers, but it worked fine in my [Music Player](https://discourse.nodered.org/t/music-player-v1-0-0/18037) project

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 April 2020 20:28 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/13 "2020-04-19T20:28:20Z")

</div>

If the command works in a terminal as the user pi then it should be possible to make it work in an exec node.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 April 2020 20:33 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/14 "2020-04-19T20:33:37Z")

</div>

> [@Colin](#):
>
> a translation of the error message

OK, worked that out myself "Error opening device or file not found".  
Put a debug node showing what is going into the exec node and also show us the config of the exec node.

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [20 April 2020 19:31 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/15 "2020-04-20T19:31:00Z")

</div>

Hi,

i tried your example now and sadly i cant stream bluetooth music and parallel the play-sound node at the same time.

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [20 April 2020 19:51 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/16 "2020-04-20T19:51:22Z")

</div>

Screenshot is taken while the musik plays via blueetooth:

 ![example](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/1/a16a3d564dc5beb9b5e6f08a32e37de7663d92b3.jpeg)

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [10 May 2020 11:23 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/17 "2020-05-10T11:23:42Z")

</div>

anyone got an idea ? 🤔

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [10 May 2020 20:21 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/18 "2020-05-10T20:21:12Z")

</div>

Hello,  
You get this error because alsa cant play two things at once. This is why alsa gives you the resource busy error.  
If you ll want to play several things to one audio output at the same time you will have to use a middleware soundserver like pulseaudio to do it im afraid. You seem to be using pulse audio for your music so you would need to play whatever you want to play from nodered through pulse audio too. Aplay tries to play it directly it seems. If you have the pulse audio utils installed you could try use paplay instead of aplay.  
Johannes

---

<div class="post-metadata">

**Author:** ![m4rten](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/m4rten/32/63353_2.png) [@m4rten](https://discourse.nodered.org/u/m4rten)\
**Post date:** [11 May 2020 17:10 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/19 "2020-05-11T17:10:46Z")

</div>

Seems there is also a problem with some permissions or something when i try to pump that command though the exec node. Via Putty it works just fine, also when iam playing in that moment a song from my mobilephone via bluetooth.

 ![2020-05-11 19_03_04-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e65581ec28a4a2d1881480e653fa0ed55eaa3d37.jpeg)

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [11 May 2020 18:28 UTC](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980/20 "2020-05-11T18:28:57Z")

</div>

your missing a `/` at the start of you file path it should be something like `/home/pi/your_audio.wav`. That’s probably why your getting the error that the file couldn’t be found and you shouldn’t need sudo.

[Next page](https://discourse.nodered.org/t/exec-node-and-terminal-problem-alsa/24980.md?page=2)
