auto reconnect for web radio

Suggestions/requests/ideas for RuneAudio core features and functions

auto reconnect for web radio

Postby flega » 10 Mar 2016, 23:04

I have Raspi and use RuneAudio to listen web radios 24/7. Problem is that everystation stop send stream to me from time to time and there is no sound, time counter is counting. Is it possible to make a script which will "listen" audio output and when is null for 5-10 seconds stoped and played again? When I do this manualy - press stop and play - stream goes again and sound is heared. It will be nice when Raspi will do this automatically when it sense there is mute on audio output and restart station.
Low cost audio for everyday use: Raspberry Pi 2 -> USB sound card ->preamp+Low-pass Filter NE5532 ->2x TDA7492 amp -> 2 fullrange speakers + 1 bass speaker.
flega
 
Posts: 28
Joined: 08 Jan 2016, 22:30
Location: Croatia

Re: auto reconnect for web radio

Postby hondagx35 » 10 Mar 2016, 23:35

Hi flega,

you can use mpd-watchdog.

- copy the script to /srv/http/command
- make it executable (chmod +x)
- use a service to start it on boot
/usr/lib/systemd/system/mpd-watchdog.service
Code: Select all
[Unit]
Description=RuneAudio MPD watchdog
After=mpd.service

[Service]
ExecStart=/var/www/command/mpd-watchdog
TimeoutSec=0
Restart=always
RestartSec=1
StartLimitInterval=30
StartLimitBurst=20

[Install]
WantedBy=multi-user.target

- enable it with "systemctl enable mpd-watchdog"

This is not tested, but tomorrow i will make some tests and report.

Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: auto reconnect for web radio

Postby flega » 11 Mar 2016, 11:02

Thank Frank,
for understanding and quick reply. I'm not very familiar with Linux, so can you give me precise step-by-step instructions after you test watchdog?
I think that watchdog is must in next release of RuneAudio, because this is a common problem but nobody knows that there is a solution for it and just stop using webradio, which is most influential media by my opinion.
Low cost audio for everyday use: Raspberry Pi 2 -> USB sound card ->preamp+Low-pass Filter NE5532 ->2x TDA7492 amp -> 2 fullrange speakers + 1 bass speaker.
flega
 
Posts: 28
Joined: 08 Jan 2016, 22:30
Location: Croatia

Re: auto reconnect for web radio

Postby PeteB » 11 Mar 2016, 19:51

@hondagx35: SUCCESS :D

At a quick pass, it seems to work as intended. Now if a stream is interrupted for a few seconds, it stops playing, and resumes a little later. The pause seems longer than the interruption in the stream, perhaps because some kind of delay or buffer is filling. (I did not have a chance to test a longer pause in the stream than a few seconds)

systemctl shows it running:
Code: Select all
....
getty@tty1.service          loaded active running   Getty on tty1
kmod-static-nodes.service   loaded active exited    Create list of required
mpd-watchdog.service        loaded active running   RuneAudio MPD watchdog
mpd.service                 loaded active running   Music Player Daemon
....

I copied and saved the script to /var/www/command so the directory path would match.
Code: Select all
/var/www/command/mpd-watchdog.sh
I added the filename extension
Code: Select all
ExecStart=/var/www/command/mpd-watchdog.sh
otherwise it does not start. If you want it saved someplace else, please advise.
(I don't really know my way around Arch well, and have no idea where scripts should go)

For test purposes, I used
Code: Select all
# systemctl start mpd-watchdog.service
and
Code: Select all
# systemctl stop mpd-watchdog.service
to get a fair test w/o a hard reboot.

TGIF lunchtime here, so it should be about "that time" in Germany, therefore - Prost!

Pete
PeteB
 
Posts: 421
Joined: 06 Feb 2016, 05:07

Re: auto reconnect for web radio

Postby flega » 11 Mar 2016, 23:36

thanks all for your time :)
but I done all you wrote me and get this in systemctrl

kmod-static-nodes.service loaded active exited Create list of required sta
* mpd-watchdog.service loaded failed failed RuneAudio MPD watchdog
mpd.service loaded active running Music Player Daemon
Low cost audio for everyday use: Raspberry Pi 2 -> USB sound card ->preamp+Low-pass Filter NE5532 ->2x TDA7492 amp -> 2 fullrange speakers + 1 bass speaker.
flega
 
Posts: 28
Joined: 08 Jan 2016, 22:30
Location: Croatia

Re: auto reconnect for web radio

Postby PeteB » 12 Mar 2016, 04:17

I got it working on the second try, with a couple small changes, documented above. Not sure what I did is 100% correct, but the service does run, and the stream starts to play on its own again.
PeteB
 
Posts: 421
Joined: 06 Feb 2016, 05:07

Re: auto reconnect for web radio

Postby flega » 13 Mar 2016, 17:59

I have little knowladge in using Linux so I done like this:
-using WinSCP create file mpd-watchdog.sh in folder /srv/http/command and paste all lines from here in that file
- go to file properties and add X to owner, group and others in permissions
- create file called mpd-watchdog.service in /usr/lib/systemd/system, paste text form hondagx35 reply, didn't change properties of file.
- use systemctl enable mpd-watchdog from Putty.
Tried several times to list systemctl and every time mpd-watchdog.service is not activated but it is loaded. Can I look somewhere error log to see why this service is not active?
Low cost audio for everyday use: Raspberry Pi 2 -> USB sound card ->preamp+Low-pass Filter NE5532 ->2x TDA7492 amp -> 2 fullrange speakers + 1 bass speaker.
flega
 
Posts: 28
Joined: 08 Jan 2016, 22:30
Location: Croatia

Re: auto reconnect for web radio

Postby PeteB » 13 Mar 2016, 18:58

flega wrote:... Tried several times to list systemctl and every time mpd-watchdog.service is not activated but it is loaded. Can I look somewhere error log to see why this service is not active?...

If even I can get it to work, it cannot be very difficult... :D

Can you try again please with two small changes I made to Frank's post? I am very interested in hearing if this works for you... I changed the directory for mpd-watchdog.sh, not the file, so you can just move it using "mv".

For example:
Code: Select all
mv /srv/http/command/mpd-watchdog.sh /var/www/command/

Then edit /usr/lib/systemd/system/mpd-watchdog.service to add .sh to the mpd-watchdog file name.

For example:
Code: Select all
nano /usr/lib/systemd/system/mpd-watchdog.service
...and save the modified file
PeteB
 
Posts: 421
Joined: 06 Feb 2016, 05:07

Re: auto reconnect for web radio

Postby flega » 13 Mar 2016, 19:26

PeteB wrote: I changed the directory for mpd-watchdog.sh, not the file, so you can just move it using "mv".

For example:
Code: Select all
mv /srv/http/command/mpd-watchdog.sh /var/www/command/



I tried to move file, but this is output:
[root@runeaudio ~]# mv: '/srv/http/command/mpd-watchdog.sh' and '/var/www/command/mpd-watchdog.sh' are the same file

I have look at content of /var and see that WWW is shortcut to /srv/http. So it seams that those are same folders and it is all the same where file is.
Low cost audio for everyday use: Raspberry Pi 2 -> USB sound card ->preamp+Low-pass Filter NE5532 ->2x TDA7492 amp -> 2 fullrange speakers + 1 bass speaker.
flega
 
Posts: 28
Joined: 08 Jan 2016, 22:30
Location: Croatia

Re: auto reconnect for web radio

Postby flega » 13 Mar 2016, 19:46

It seems it work! I add .sh to the mpd-watchdog file name in /usr/lib/systemd/system/mpd-watchdog.service, restart Raspi and now is in systemctl this:

Code: Select all
kmod-static-nodes.service   loaded active exited    Create list of required stat
mpd-watchdog.service        loaded active running   RuneAudio MPD watchdog
mpd.service                 loaded active running   Music Player Daemon


How can I test is this service work properly? I know I can wait for a day or two :) but how did you test it ?
Last edited by flega on 13 Mar 2016, 19:58, edited 1 time in total.
Low cost audio for everyday use: Raspberry Pi 2 -> USB sound card ->preamp+Low-pass Filter NE5532 ->2x TDA7492 amp -> 2 fullrange speakers + 1 bass speaker.
flega
 
Posts: 28
Joined: 08 Jan 2016, 22:30
Location: Croatia

support RuneAudio Donate with PayPal

Next

Return to Feature request

Who is online

Users browsing this forum: No registered users and 1 guest