philippe44 / LMS-ShairTunes2W

Airtunes with LMS (fork of https://github.com/disaster123/shairport2_plugin)
63 stars 3 forks source link

Unable to discover the players #40

Closed cthulu closed 2 years ago

cthulu commented 2 years ago

Hi I'm using LMS in a Docker, with Host networking. However I am not able to see the players in Airplay, despite this in the LMS logs:

 tail server.log                                                                                                      
[21-11-16 09:17:27.5034] Slim::Web::Cometd::handler (421) errorNeedsClient: 00:04:20:2b:56:b8, status, -, 10, menu:menu, useContextMenu:1, subscribe
:600                                                                                                                                                
[21-11-16 09:17:28.1948] Plugins::ShairTunes2W::Plugin::playerSubscriptionChange (319) request=client new client=Slim::Player::SqueezePlay=ARRAY(0x9
55be78) 00:04:20:2b:56:b8                                                                                                                           
[21-11-16 09:17:28.1961] Plugins::ShairTunes2W::Plugin::createListenPort (398) Created listener on port 36586                                       
[21-11-16 09:17:28.1973] Plugins::ShairTunes2W::Plugin::publishPlayer (434) start avahi-publish-service "Squeezebox Radio"                          
[21-11-16 09:17:28.2055] Plugins::ShairTunes2W::Plugin::addPlayer (346) create client Slim::Player::SqueezePlay=ARRAY(0x955be78) with proc Proc::Bac
kground=HASH(0x96d1760)                                                                                                                             
[21-11-16 09:18:26.7193] Plugins::ShairTunes2W::Plugin::revoke_publishPlayers (410) Stop old publish players services:60                            
[21-11-16 09:18:26.7200] Plugins::ShairTunes2W::Plugin::removePlayer (358) publisher for Squeezebox Radio with 00:04:20:2b:56:b8, PID Proc::Backgrou
nd=HASH(0x96d1760) will be terminated.                                                                                                              
[21-11-16 09:18:26.7218] Plugins::ShairTunes2W::Plugin::createListenPort (398) Created listener on port 37150                                       
[21-11-16 09:18:26.7233] Plugins::ShairTunes2W::Plugin::publishPlayer (434) start avahi-publish-service "Squeezebox Radio"                          
[21-11-16 09:18:26.7325] Plugins::ShairTunes2W::Plugin::addPlayer (346) create client Slim::Player::SqueezePlay=ARRAY(0x955be78) with proc Proc::Bac
kground=HASH(0x9663818)
cthulu commented 2 years ago

I am not sure what can be wrong, because the Host networking is should forward all Avahi publishing etc

philippe44 commented 2 years ago

Your router is probably doing IGMP snooping or some broadcast filtering.

cthulu commented 2 years ago

That would affect any multicast traffic right? Other multicast traffic (chromecast and other airplay) doesn't seem to be affected

On Tue, 16 Nov 2021, 18:40 philippe44, @.***> wrote:

Your router is probably doing IGMP snooping or some broadcast filtering.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/philippe44/ShairTunes2/issues/40#issuecomment-970509400, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI7OEE3JR5ZHDUMAWWA4STUMKJR5ANCNFSM5IDYVWGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

philippe44 commented 2 years ago

It depends if that multicast traffic has to cross network PHY boundaries. For example, if you use AirPlay from you iPhone to a speaker, both on WiFi, no problem will occur.

cthulu commented 2 years ago

I think that multicast might not necessarily be the issue. One thing that I noticed is:

[21-11-16 19:38:29.6132] Plugins::ShairTunes2W::Plugin::revoke_publishPlayers (410) Stop old publish players services:83
[21-11-16 19:38:29.6139] Plugins::ShairTunes2W::Plugin::removePlayer (358) publisher for Squeezebox Radio with 00:04:20:2b:56:b8, PID Proc::Background=HASH(0x9bc3370) will be terminated.
[21-11-16 19:38:29.6151] Plugins::ShairTunes2W::Plugin::createListenPort (398) Created listener on port 48445
[21-11-16 19:38:29.6160] Plugins::ShairTunes2W::Plugin::publishPlayer (434) start avahi-publish-service "Squeezebox Radio"
[21-11-16 19:38:29.6240] Plugins::ShairTunes2W::Plugin::addPlayer (346) create client Slim::Player::SqueezePlay=ARRAY(0x955be78) with proc Proc::Background=HASH(0xa420a08)
Failed to create client object: Daemon not running

The last message Failed to create client object: Daemon not running. Where does it come from?

philippe44 commented 2 years ago

Look at Avahi instances running then and there might be an issue with your Avahi configuration. Otherwise, you can try to force use of the built-in helper for mDNS by commenting-out these lines in Plugin.pm (cache/InstalledPlugins/Plugins/ShairTunes2W)

    if ( $path = which('avahi-publish-service') ) {
        $log->info( "start avahi-publish-service \"$apname\"" );
        $mDNShelper = $path;
        eval { $proc = Proc::Background->new( $path, $id, "_raop._tcp", $port, @params ); };
        return $proc if $proc;
        $log->warn( "start avahi-publish-service failed" );
    }   
    $log->info( "avahi-publish-player not in path" ) if (!$@);

    if ( $path = which('dns-sd') ) {
        $log->info( "start dns-sd \"$apname\"" );
        $mDNShelper = $path;
        eval { $proc = Proc::Background->new( $path, '-R', $id, "_raop._tcp", ".", @params ); };
        return $proc if $proc;
        $log->warn( "start dns-sd failed" );
    }
    $log->info( "dns-sd not in path" ) if (!$@);

    if ( $path = which('mDNSPublish') ) {
        $log->info( "start mDNSPublish \"$apname\"" );
        $mDNShelper = $path;
        eval { $proc = Proc::Background->new($path, $id, "_raop._tcp", @params ); };
        return $proc if $proc;
        $log->warn( "start mDNSPublish failed" );
    }
    $log->info( "mDNSPublish not in path" ) if (!$@);

If Avahi is running, you have to make sure it shares port 5353. I don't remember the exact option, but in the past Avahi was grabbing it for exclusive usage.

cthulu commented 2 years ago

Good point! It looks like the docker image I am using did have avahi-publish-service binary but not the deamon running, so I have completely disabled that code path and now it works! I can see the Squeezebox Radio and play via Airplay from my iPad! Thanks for that idea!

I still have an issue connecting from my Macbook tho - it sees the device but when I try to connect it just says Could not connect to “Squeezebox Radio”. I am pretty sure it's because iPad uses different Airplay version than Mac, but maybe you know if there is a way to fix it?

cthulu commented 2 years ago

Okay, definitely something on my side - I have tried another Macbook and it connects fine ¯_(ツ)_/¯

I think my main problem was the Docker not having avahi-daemon running but the binaries available which confused the logic in the code.

Thanks a lot for your help!