Closed davidandreoletti closed 7 months ago
Does ping resolve the name?
Does ping resolve the name?
Yes
ping snapserver.audio.mediacenter.home
PING my-machine-hw1.lan (192.168.3.1): 56 data bytes
64 bytes from 192.168.3.1: icmp_seq=0 ttl=64 time=2.232 ms
Please try the latest version of the develop branch, it will log all resolved IP addresses.
I installed this snapcast_armhf-debian-bookworm-1184cf1db39e6106a3442ae92e92f5b872ac1b62's snapclient binary
Logs with CNAME record:
/usr/bin/snapclient --host=snapserver.audio.mediacenter.home --port=1704 --hostID='davida-audiospeaker-hw0' --instance=1 --priority=-6 --logsink=stdout --logfilter='*:debug'
2024-03-28 04-23-56.876 [Debug] (Snapclient) Trying to get PCM device for player: alsa, parameter: , card: default
2024-03-28 04-23-56.960 [Info] (Snapclient) Version 0.28.0.1, revision 1184cf1d
2024-03-28 04-23-56.960 [Info] (Connection) Resolving host IP for: snapserver.audio.mediacenter.home
2024-03-28 04-23-56.968 [Debug] (Connection) Resolved IP: fd5e:29da:e475::1
2024-03-28 04-23-56.968 [Debug] (Connection) Resolved IP: 192.168.3.1
2024-03-28 04-23-56.968 [Info] (Connection) Connecting to [fd5e:29da:e475::1]:1704
2024-03-28 04-23-56.972 [Error] (Connection) Failed to connect to host 'snapserver.audio.mediacenter.home', error: Connection refused
2024-03-28 04-23-56.972 [Error] (Controller) Error: Connection refused
2024-03-28 04-23-56.972 [Debug] (Connection) Disconnecting
2024-03-28 04-23-56.972 [Error] (Connection) Error in socket shutdown: Transport endpoint is not connected
Log without CNAME record:
/usr/bin/snapclient --host=192.168.3.1 --port=1704 --hostID='davida-audiospeaker-hw0' --instance=1 --priority=-6 --logsink=stdout --logfilter='*:debug'
024-03-28 04-25-57.667 [Debug] (Snapclient) Trying to get PCM device for player: alsa, parameter: , card: default
2024-03-28 04-25-57.711 [Info] (Snapclient) Version 0.28.0.1, revision 1184cf1d
2024-03-28 04-25-57.712 [Info] (Connection) Resolving host IP for: 192.168.3.1
2024-03-28 04-25-57.712 [Debug] (Connection) Resolved IP: 192.168.3.1
2024-03-28 04-25-57.712 [Info] (Connection) Connecting to 192.168.3.1:1704
2024-03-28 04-25-57.715 [Notice] (Connection) Connected to 192.168.3.1
2024-03-28 04-25-57.716 [Info] (Connection) My MAC: "02:51:03:41:2e:99", socket: 8
So the snapclient is connecting with a IPv6 address fd5e....
to the snapserver and the snapserver is not listening on IPv6 by default.
I configured IPv6 support for snapserver (v0.28.0 beta1) and the client can now connect successfully.
/usr/bin/snapclient --host=snapserver.audio.mediacenter.home --port=1704 --hostID='davida-audiospeaker-hw0' --instance=1 --priority=-6 --logsink=stdout --logfilter='*:debug'
2024-03-28 04-41-52.536 [Debug] (Snapclient) Trying to get PCM device for player: alsa, parameter: , card: default
2024-03-28 04-41-52.654 [Info] (Snapclient) Version 0.28.0.1, revision 1184cf1d
2024-03-28 04-41-52.654 [Info] (Connection) Resolving host IP for: snapserver.audio.mediacenter.home
2024-03-28 04-41-52.670 [Debug] (Connection) Resolved IP: fd5e:29da:e475::1
2024-03-28 04-41-52.670 [Debug] (Connection) Resolved IP: 192.168.3.1
2024-03-28 04-41-52.670 [Info] (Connection) Connecting to [fd5e:29da:e475::1]:1704
2024-03-28 04-41-52.677 [Notice] (Connection) Connected to fd5e:29da:e475::1
2024-03-28 04-41-52.678 [Info] (Connection) My MAC: "02:51:03:41:2e:99", socket
@badaix What do you suggest to get the snapclient to prefer IPv4 over IPv6 when both IPs are resolved ?
I don't know what the best practice is to give a hint to a client on what kind of IP address to resolve, but I think it doesn't make sense to not try other resolved addresses, if the first one is not working. So I've added a loop through all IP addresses, in case a connection attempt failed. You can find packages here: https://github.com/badaix/snapcast/actions/runs/8465628529
I don't know what the best practice is to give a hint to a client on what kind of IP address to resolve, but I think it doesn't make sense to not try other resolved addresses, if the first one is not working. So I've added a loop through all IP addresses, in case a connection attempt failed. You can find packages here: https://github.com/badaix/snapcast/actions/runs/8465628529
Both resolved IPs are tried and eventually one succeeds.
024-04-01 09-14-28.926 [Debug] (Connection) Disconnected
2024-04-01 09-14-29.926 [Info] (Connection) Resolving host IP for: snapserver.audio.mediacenter.home
2024-04-01 09-14-29.929 [Debug] (Connection) Resolved IP: fdd1:f583:cc37::1
2024-04-01 09-14-29.929 [Debug] (Connection) Resolved IP: 192.168.3.1
2024-04-01 09-14-29.929 [Info] (Connection) Connecting to [fdd1:f583:cc37::1]:1704
2024-04-01 09-14-29.930 [Info] (Connection) Connecting to 192.168.3.1:1704
2024-04-01 09-14-29.932 [Error] (Connection) Failed to connect to host 'snapserver.audio.mediacenter.home', error: Connection refused
2024-04-01 09-14-29.932 [Error] (Controller) Error: Connection refused
2024-04-01 09-14-29.932 [Debug] (Connection) Disconnecting
2024-04-01 09-14-29.932 [Error] (Connection) Error in socket shutdown: Transport endpoint is not connected
2024-04-01 09-14-29.932 [Debug] (Connection) Disconnected
2024-04-01 09-14-30.933 [Info] (Connection) Resolving host IP for: snapserver.audio.mediacenter.home
2024-04-01 09-15-06.620 [Error] (Connection) Failed to resolve host 'snapserver.audio.mediacenter.home', error: Host not found (authoritative)
2024-04-01 09-15-06.620 [Error] (Controller) Error: Host not found (authoritative)
2024-04-01 09-15-06.620 [Debug] (Connection) Disconnecting
2024-04-01 09-15-06.621 [Debug] (Connection) Not connected
2024-04-01 09-15-07.621 [Info] (Connection) Resolving host IP for: snapserver.audio.mediacenter.home
2024-04-01 09-15-19.919 [Error] (Connection) Failed to resolve host 'snapserver.audio.mediacenter.home', error: Host not found (authoritative)
2024-04-01 09-15-19.919 [Error] (Controller) Error: Host not found (authoritative)
2024-04-01 09-15-19.919 [Debug] (Connection) Disconnecting
2024-04-01 09-15-19.919 [Debug] (Connection) Not connected
2024-04-01 09-15-20.920 [Info] (Connection) Resolving host IP for: snapserver.audio.mediacenter.home
2024-04-01 09-15-20.929 [Debug] (Connection) Resolved IP: 192.168.3.1
2024-04-01 09-15-20.930 [Info] (Connection) Connecting to 192.168.3.1:1704
2024-04-01 09-15-20.936 [Notice] (Connection) Connected to 192.168.3.1
Bug resolved. Thank you @badaix
Describe the bug snapclient fails to connect to snapserver when the hostname is a CNAME while using snapserver's host IP connects successfully.
Steps to Reproduce
snapclient --host='some.cname.dns.record'
snapclient --host='ip.of.server'
Environment details
Attach logfile if applicable Generate logs with
snapclient --logfilter debug
orsnapserver --logging.filter debug
if possible and paste them in the following codeblockLogs when connections fails
Logs when connections succeeds
DNS record:
Investigation
Looks like snapclient's performs no name resolution by default due to numeric_service.html