Moode Forum
MPD: Failed to bind socket: Address already in use - Printable Version

+- Moode Forum (http://moodeaudio.org/forum)
+-- Forum: moOde audio player (http://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (http://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: MPD: Failed to bind socket: Address already in use (/showthread.php?tid=2092)



MPD: Failed to bind socket: Address already in use - mohel - 01-18-2020

Hello,

I installed moode on a raspberry Z W as described in the setup guide and everything works fine. Only access to mpd server over some clients did not work. I found you, that some clients resolve the hostname to an IPV6 adress of the raspberry. Using IPV6 the access does not work, with IPV4 it works fine.

With some internet help I get to the following error when MPD is started manually (also stopped mpd mannuelly berforehand and check with ps ax):


Code:
pi@MusikBadOG:~ $ mpd --no-daemon --stdout --verbose /etc/mpd.conf
config_file: loading file /etc/mpd.conf
exception: Failed to bind to '0.0.0.0:6600'
exception: nested: Failed to bind socket: Address already in use
afterwards port 6600 is only opnened with V4 and not V6 (check with netstat -l).

/etc/mpd.conf contains the following:
Code:
bind_to_address "any"
port "6600"




Also played around a little bit with /proc/sys/net/ipv6/bindv6only tried 0 and 1 as values, but doesn't change anything.

What can I do to have port 6600 available on IPv4 and IPv6 at the same time?`
Thanks!


RE: MPD: Failed to bind socket: Address already in use - TheOldPresbyope - 01-18-2020

@mohel

Interesting question.

I have no practical experience configuring dual-stack systems but I had been led to believe that the port issue is handled automagically. Apparently not.

The only dual-stack systems on my LAN are my moOde players. Running netstat on one confirms what you say:

Code:
pi@moodeCD:~ $ sudo netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:6600            0.0.0.0:*               LISTEN      2064/mpd            
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      632/smbd            
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/init              
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      579/nginx: master p
tcp        0      0 0.0.0.0:48753           0.0.0.0:*               LISTEN      1799/php-fpm: pool  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      562/sshd            
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      632/smbd            
tcp        0      0 0.0.0.0:33951           0.0.0.0:*               LISTEN      1815/php-fpm: pool  
tcp6       0      0 :::139                  :::*                    LISTEN      632/smbd            
tcp6       0      0 :::111                  :::*                    LISTEN      1/init              
tcp6       0      0 :::22                   :::*                    LISTEN      562/sshd            
tcp6       0      0 :::445                  :::*                    LISTEN      632/smbd            

I'll poke around because I'm curious but maybe someone else already knows the answer.

Regards,
Kent


RE: MPD: Failed to bind socket: Address already in use - Tim Curtis - 01-18-2020

(01-18-2020, 01:08 PM)mohel Wrote: Hello,

I installed moode on a raspberry Z W as described in the setup guide and everything works fine. Only access to mpd server over some clients did not work. I found you, that some clients resolve the hostname to an IPV6 adress of the raspberry. Using IPV6 the access does not work, with IPV4 it works fine.

With some internet help I get to the following error when MPD is started manually (also stopped mpd mannuelly berforehand and check with ps ax):


Code:
pi@MusikBadOG:~ $ mpd --no-daemon --stdout --verbose /etc/mpd.conf
config_file: loading file /etc/mpd.conf
exception: Failed to bind to '0.0.0.0:6600'
exception: nested: Failed to bind socket: Address already in use
afterwards port 6600 is only opnened with V4 and not V6 (check with netstat -l).

/etc/mpd.conf contains the following:
Code:
bind_to_address "any"
port "6600"




Also played around a little bit with /proc/sys/net/ipv6/bindv6only tried 0 and 1 as values, but doesn't change anything.

What can I do to have port 6600 available on IPv4 and IPv6 at the same time?`
Thanks!

What clients are you talking about?

moOde access MPD via localhost.


RE: MPD: Failed to bind socket: Address already in use - TheOldPresbyope - 01-18-2020

@mohel

On the specific question of MPD, which is the listener on port 6600, have a look at STEP 6 of moOde's build recipe. The MPD compile option list in item 4 of this step includes "--disable-ipv6".

You can follow the instructions in this step to build a new copy of MPD with IPv6 support enabled and see if this solves your problem.

You should be aware that a number of blog and forum posts can be found on the Web commenting on problems relating to MPD listening to IPv4 and IPv6. Some posters offer configuration "fixes". This suggests proceeding cautiously.
 

Regards,
Kent


RE: MPD: Failed to bind socket: Address already in use - mohel - 01-26-2020

Hello,

sorry for the late resposne but had some private topics.

@Tim Curtis:
I tested access with M.A.L.P. on Android and Cantata on Windows 10. Using both on local network with Fritzbox 7590 as DNS Server for local requests. Both resolve to the IPV6 address so I need to configure the IPV4 adress as fixed value and connot use the hostname.


@TheOldPresbyope:
Thanks for the infomration. The problem is, that when I change mpd.conf to:

Code:
bind_to_address "::"
port "6600"

and test again I get the following:

Code:
pi@MusikBadOG:~ $ mpd --no-daemon --stdout --verbose /etc/mpd.conf
config_file: loading file /etc/mpd.conf
exception: Failed to bind to ':::6600'
exception: nested: Failed to bind socket: Address already in use
pi@MusikBadOG:~ $ netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:32975           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:http            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:58265           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:49469           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:microsoft-ds    0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:41735           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:netbios-ssn     0.0.0.0:*               LISTEN
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
tcp6       0      0 [::]:microsoft-ds       [::]:*                  LISTEN
tcp6       0      0 [::]:6600               [::]:*                  LISTEN
tcp6       0      0 [::]:netbios-ssn        [::]:*                  LISTEN
[...]

So IPV6 support seems to be implemented, because then I can connect using IPV6 (but only).

Any other suggestions? :-)

Thanks for your help!


RE: MPD: Failed to bind socket: Address already in use - Tim Curtis - 01-26-2020

(01-26-2020, 06:59 PM)mohel Wrote: Hello,

sorry for the late resposne but had some private topics.

@Tim Curtis:
I tested access with M.A.L.P. on Android and Cantata on Windows 10. Using both on local network with Fritzbox 7590 as DNS Server for local requests. Both resolve to the IPV6 address so I need to configure the IPV4 adress as fixed value and connot use the hostname.

I don't provide any support whatsoever for these external clients. You should contact their project maintainers for support.


RE: MPD: Failed to bind socket: Address already in use - mohel - 01-27-2020

(01-26-2020, 07:26 PM)Tim Curtis Wrote:
(01-26-2020, 06:59 PM)mohel Wrote: Hello,

sorry for the late resposne but had some private topics.

@Tim Curtis:
I tested access with M.A.L.P. on Android and Cantata on Windows 10. Using both on local network with Fritzbox 7590 as DNS Server for local requests. Both resolve to the IPV6 address so I need to configure the IPV4 adress as fixed value and connot use the hostname.

I don't provide any support whatsoever for these external clients. You should contact their project maintainers for support.

Yea I understand absoltely, but in my opinion this is not a client specific error, because every systeme that uses IPV6 to resolve has the same error. Because when I configure these clients with the IPv4 adress this works correct. So from point of view the mpd server has problems to use port 6600 on IPv4 and IPv6 simultaneously.


RE: MPD: Failed to bind socket: Address already in use - Tim Curtis - 01-27-2020

Try posting the question in MPD Git repo.
https://github.com/MusicPlayerDaemon/MPD/issues


RE: MPD: Failed to bind socket: Address already in use - TheOldPresbyope - 01-28-2020

@mohel

You didn't say, but I assume you did rebuild mpd to include IPv6 support so it now shows up as an "other feature"

Code:
pi@moodecd:~ $ mpd --version
Music Player Daemon 0.21.16 (0.21.16)
...
Other features:
avahi epoll icu inotify ipv6 systemd tcp un

                        ^^^^

I'm going to ignore the fail_to_bind messages you're showing because it appears you're trying to start a second copy of mpd. Mutiple copies can't use the same port(s).

When I overwrite /usr/local/bin/mpd with my rebuilt mpd, update the cfg_mpd table in /var/local/www/db/moode-sqlite3.db to reflect the change in the value of "bind_to_address", and reboot, I get essentially the same netstat output as you. 

However, even though netstat suggests my rebuilt mpd is listening only for IPv6 connections on port 6600, I'm able to connect to it via IPv4. This seems to contradict what you said earlier.

Here, from Linux host T520 connecting to my rebuilt mpd running on host moodecd:
 
Code:
xxxx@T520 ~ $ telnet -4 moodecd 6600
Trying 192.168.1.201...
Connected to moodecd.fios-router.home.
Escape character is '^]'.
OK MPD 0.21.11
<<<note that this is actually MPD 0.21.16 but apparently the source code wasn't thoroughly checked>>>


I think other tools like ss and lsof may be more useful than netstat in understanding this but I'm not expert in interpreting their output in a dual-stack network environment.

Looking at the following output from a moOde 6.4.1 player

Code:
pi@moodecd:~ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
   inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
   link/ether dc:a6:32:0e:e6:25 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
   link/ether dc:a6:32:0e:e6:26 brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.201/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
      valid_lft 78277sec preferred_lft 67477sec
   inet6 fe80::fda3:28fc:3e8a:d83c/64 scope link
      valid_lft forever preferred_lft forever

it would seem that a moOde player (which is to say, Raspbian) does set up IPv6 support but only enables link-local addresses ("scope link"). 

This suggests that competent pull requests posted to the moOde repo are in order. Who's up to the task? Not me. I can spell IPv6 but I can't claim a working knowledge of it. Setting up global (e.g., routable) IPv6 addresses, setting up dual IPv4/IPv6 DNS---yada yada yada---haven't done it.


Regards,
Kent


RE: MPD: Failed to bind socket: Address already in use - Tim Curtis - 01-28-2020

Kent, this is not a moOde issue.