Help Wizard

Step 1

NEXT STEP

Who Me Too'd this topic

Spotify Connect not working when localhost resolves to more than one address

 Device

Galaxy S7 running LineageOS

Operating System

Android 7 Nougat

 

My Question or Issue

On my Android device, Spotify sends the mDNS broadcasts over the lo interface due to the following bug in the Spotify mDNS implementation.

 

First, the system's hostname is retrieved with boost::asio::ip::host_name. That hostname is looked up using boost::asio::ip::udp:resolver::resolve, and then, if more than one hostname is returned, the mDNS broadcast socket is bound to any found IPv4 addresses using boost::asio::ip::udp::socket::set_option(boost::asio::ip::multicast::outbound_interface).

 

On my system, and many others (see https://github.com/AdAway/AdAway/issues/1009 and https://github.com/StevenBlack/hosts/issues/619), the gethostname call returns localhost, and localhost resolves to 127.0.0.1 as well as ::1 due to corresponding default entries in /system/etc/hosts. This will cause the socket to bind to 127.0.0.1 and therefore the mDNS broadcast requests are sent over lo instead of wlan0, never reaching the intended targets. I can reproduce the issue by adding and removing the line "::1 localhost" from /system/etc/hosts, and I will see the udp port 5353 packets on wlan0 or lo, respectively.

Who Me Too'd this topic