When moh audio stream ends; never recovers

I ended up giving up on this method, and used this instead:

sudo apt install madplay
sudo mkdir /var/lib/asterisk/mohmp3-empty
sudo touch /var/lib/asterisk/mohmp3-empty/moh.mp3
cd /etc/asterisk
sudo nano mohstream.sh

In mohstream.sh:

#!/bin/bash
/usr/bin/wget -q -O - https://my.icecastserver.com/live.mp3 | /usr/bin/madplay -Q -z -o raw:- --mono -R 8000 -a -12 -

Save and exit nano.
sudo chmod a+x mohstream.sh

In musiconhold.conf

[ulawstream]
mode=custom
dir=/var/lib/asterisk/mohmp3-empty
application=/etc/asterisk/mohstream.sh

sudo systemctl restart asterisk

Now, when I call in and am listening to moh, and I stop the stream, and in the asterisk console (sudo asterisk -rvv) I get the warning: res_musiconhold.c:809 monmp3thread: poll() failed: Interrupted system call when the stream is stopped… but it ends up being fine. I can start the stream again, and I can resume listening.

If you want to check to see if the script is running, you can do ps aux and the script should be in the list of things running.

1 Like