hzeller / gmrender-resurrect

Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
GNU General Public License v2.0
842 stars 204 forks source link

[error] UPNP_E_SOCKET_ERROR (-208) #129

Closed coolbombom closed 6 years ago

coolbombom commented 7 years ago

Hi

first off, thank for all the hard work.

I'm trying to run this on a hummingbird board, but i keep getting following error ... i can't figure out what is wrong!

gmediarender 0.0.7-git started [ gmediarender 2017-03-18_33600ab (libupnp-1.6.19+git20160116; glib-2.48.2; gstreamer-1.8.3) ].
Logging switched off. Enable with --logfile=<filename> (e.g. --logfile=/dev/stdout for console)
ERROR [2017-06-11 10:20:33.230763 | upnp] UpnpInit(ip=(null), port=49494) Error: UPNP_E_SOCKET_ERROR (-208)
ERROR [2017-06-11 10:20:33.230869 | main] ERROR: Failed to initialize UPnP device

EDIT: i'm running it on the latest version of armbian

please help

cheers c_bb

hzeller commented 7 years ago

Maybe it had trouble binding to some IP ? In particular if you have multiple interfaces (eth0 and some wlan), you need to decides that with explicitly setting the IP address to be bound to with the --ip-address option. Maybe this is the issue ?

Wesley-Chan commented 6 years ago

I have this exact issue when trying to launch gmediarender from init.d script. My rig's running Gentoo and OpenRC. I also tried the -I option which won't work either. But if I manually start the service later when the system has fully booted, it would work. I don't quite understand the dependencies. Maybe you have some advise, @hzeller? Thanks in advance.

gaydenko commented 6 years ago

At my case setting --ip-address doesn't help. Error message just contains that IP instead of null. I have set that IP is assigned if I manually (successfully) start the systemd service after boot.

ERROR [2018-01-29 13:59:19.911878 | upnp] UpnpInit(ip=192.168.1.103, port=49494) Error: UPNP_E_SOCKET_BIND (-203)
ERROR [2018-01-29 13:59:19.911923 | main] ERROR: Failed to initialize UPnP device

Any further directions to dig in?

hzeller commented 6 years ago

Did you arrange the init dependencies in a way to start gmrender-resurrect after the network is up?

gaydenko commented 6 years ago

Yes. This is the systemd service:

[Unit]
Description=UPnP renderer using gstreamer
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/gmediarender -f "gMedia UpPnP Renderer" -u 49e4f137-a832-481c-9117-bfa96a71aba5

[Install]
WantedBy=default.target

And this is ExecStart tuning (that is override.conf):

[Service]
ExecStart=
ExecStart=/usr/bin/gmediarender -f Anli_gRenderer -u b5f87cc9-c9d6-4f6f-ac04-7665d4c189a6 --gstout-audiosink=alsasink --gstout-audiodevice=iec958 --logfile=/home/andrew/.local/log/gmediarender.log --ip-address=192.168.1.103

On manual service start all is OK.

mill1000 commented 6 years ago

Perhaps try another WantedBy target? I am using systemd on my RPi3 and haven't had issues. Here is my service.

[Unit]
Description=GMediaRender
After=syslog.service network.target

[Service]
ExecStart=/usr/local/bin/gmediarender -f %H
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=GMediaRender
User=pi
Group=audio

[Install]
WantedBy=multi-user.target

I am using a locally compiled version so my path is in /usr/local/bin instead of /usr/bin

If that doesn't work trying delaying the execution of the service with the following ExecStartPre=/bin/sleep 3

Maybe the network is still coming up when the service starts and that causes an issue.

gaydenko commented 6 years ago

@mill1000 thanks! - the trick with ExecStartPre is that tick which did it!

sonvirgo commented 6 years ago

I have same error on os x High Sierra. It works for 2 days, then stop now. Your trick doesn't work. What now?

sonvirgo commented 6 years ago

#157 I thinks MiniDLNA shares libupnp but it use it own upnp. Also SO_REUSEADDR does not work as expected for datagram sockets on Mac OS X. Thanks

P/s however the PORT reported is incorrect. After an hour of LLDB debug, I found the conflict port is 1900 SSDP_PORT.

hzeller commented 6 years ago

I could reproduce this with a current debian installation. It seems like the systemd targets network.target and network-online.target are actually not waiting until all networks are configured so the UPnP socket initialization might fail.

Now, gmrender-resurrect does retries (up to a minute) to attempt establishing the socket. It now reliably initializes the service on a systemd configured system.

whyman commented 6 years ago

I'm pretty sure libupnp 1.6 tries to bind every interface even if you set one explicitly. Works with 1.8 correctly as far as I have seen.

neumantm commented 1 year ago

I know, old thread. But for anyone stumbling upon this in the future: I just added the following to my systemd unit and now it seems to work without retries and without any ugly sleep:

[Unit]
Description=gmrender-resurrect
After=network-online.target sound.target
Requires=network-online.target sound.target

I'm not sure if the sound.target is really required, but it made sense to me. Important thing is that we use network-online.target and not network.target and that we add it in After and in Requires.