badaix / snapcast

Synchronous multiroom audio player
GNU General Public License v3.0
6.21k stars 456 forks source link

snapserver: `Error creating TCP acceptor: bind: Address in use` when binding to the same port with IPv4 and IPv6 #1217

Closed davidandreoletti closed 7 months ago

davidandreoletti commented 7 months ago

Describe the bug Snapserver reports bind: address in use for port 1704, 1705,1780 despite no other process listening on these port (via netstat)

Steps to Reproduce

  1. snapserver --server.threads=2 --server.user=root --server.group=root --stream.port=1704 --stream.bind_to_address=0.0.0.0 --stream.bind_to_address=:: --http.enabled=true --http.bind_to_address=0.0.0.0 --http.bind_to_address=:: --http.port=1780 --tcp.enabled=true --tcp.bind_to_address=0.0.0.0 --tcp.bind_to_address=:: --tcp.port=1705
  2. kill -9 $(pgrep snapserver)
  3. Run step 1's command again.

Environment details

5 [Info] (Snapserver) Version 0.28.0.1
2024-04-01 23-14-16.596 [Info] (Snapserver) Adding source: pipe:///tmp/snapfifo?name=default
...
2024-04-01 23-14-16.630 [Info] (PcmEnc) Init
2024-04-01 23-14-16.630 [Info] (FlacEnc) Init - compression level: 2
2024-04-01 23-14-16.630 [Info] (ControlServer) Creating TCP acceptor for address: 0.0.0.0, port: 1705
2024-04-01 23-14-16.631 [Info] (ControlServer) Creating TCP acceptor for address: ::, port: 1705
2024-04-01 23-14-16.638 [Error] (ControlServer) error creating TCP acceptor: bind: Address in use [system:98 at /var/tmp/openwrt/build/package/davida-router-hw1/friendlyarm_nanopi-r4s/package/openwrt-sdk-Linux-x86_64/staging_dir/target-aarch64_generic_musl/usr/include/boost/asio/detail/reactive_socket_service.hpp:161 in function 'bind'], code: system:98
2024-04-01 23-14-16.639 [Info] (ControlServer) Creating HTTP acceptor for address: 0.0.0.0, port: 1780
2024-04-01 23-14-16.639 [Info] (ControlServer) Creating HTTP acceptor for address: ::, port: 1780
2024-04-01 23-14-16.639 [Error] (ControlServer) error creating HTTP acceptor: bind: Address in use [system:98 at /var/tmp/openwrt/build/package/davida-router-hw1/friendlyarm_nanopi-r4s/package/openwrt-sdk-Linux-x86_64/staging_dir/target-aarch64_generic_musl/usr/include/boost/asio/detail/reactive_socket_service.hpp:161 in function 'bind'], code: system:98
2024-04-01 23-14-16.640 [Info] (StreamServer) Creating stream acceptor for address: 0.0.0.0, port: 1704
2024-04-01 23-14-16.640 [Info] (StreamServer) Creating stream acceptor for address: ::, port: 1704
2024-04-01 23-14-16.640 [Error] (StreamServer) error creating TCP acceptor: bind: Address in use [system:98 at /var/tmp/openwrt/build/package/davida-router-hw1/friendlyarm_nanopi-r4s/package/openwrt-sdk-Linux-x86_64/staging_dir/target-aarch64_generic_musl/usr/include/boost/asio/detail/reactive_socket_service.hpp:161 in function 'bind'], code: system:98
2024-04-01 23-14-16.641 [Info] (Snapserver) Number of threads: 2, hw threads: 6

Investigation

Workaround

badaix commented 7 months ago

I think that the socket is not an IP_V6ONLY socket, and thus :: should accept IPv4 and IPv6, so please try to remove the binds to 0.0.0.0

davidandreoletti commented 7 months ago

Using :: allow IPv4 an IPv6 client to connect.