Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Zeroconf based Authentication #998

Closed
jonkerj opened this issue Sep 6, 2021 · 12 comments
Closed

Support Zeroconf based Authentication #998

jonkerj opened this issue Sep 6, 2021 · 12 comments
Labels
enhancement A new feature that would improve Spotifyd

Comments

@jonkerj
Copy link

jonkerj commented Sep 6, 2021

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
I'd like spotifyd to have a mode in which is does not require credentials in the config file, but plays "on behalf" of the initiating spotify connect client (eg my iPhone). I know this is possible, as the Spotify Android app on my mibox/chromecast behaves this way. When the device is turned on, any spotify client can play "through" this device over (I assume) spotify connect. I know fairly sure I am not "casting", as it shows "Spotify Connect" next to the device.

When I dump traffic between iPhone and mibox, I see a lot of spotify-related mDNS going on.

This "mode" probably has a proper name, if anyone know this, I'll update the issue title.

Describe alternatives you've considered
It could very well be that this is already possible, I tried to launch spotifyd without credentials and with Avahi running, but could not get it running. If it's possible, I'd like to see how, of course :-)

@jonkerj jonkerj added the enhancement A new feature that would improve Spotifyd label Sep 6, 2021
@JojiiOfficial JojiiOfficial changed the title Public/anonymous access Support Zeroconf based Authentication Sep 6, 2021
@JojiiOfficial
Copy link
Member

Correct me if I'm wrong but it should work by removing all credential providing config options. Although when I tried this, I couldn't select my PC as playback device in the App (it was grayed out but available). The logs confirmed my phone trying to use it as device but for some reason it failed.

@jonkerj
Copy link
Author

jonkerj commented Sep 7, 2021

It was not very clear to me (at least from the docs) if this should work or not. When running in verbose mode, it does show mdns interaction indeed, but it does not work.

So, is it a bug or a missing feature?

@klarkc
Copy link

klarkc commented Sep 17, 2021

Same here, I just tried without password or username:

set 17 10:39:13 ssdinarch systemd[424]: Started A spotify playing daemon.
set 17 10:39:13 ssdinarch spotifyd[39915]: Loading config from "/home/klarkc/.config/spotifyd"
set 17 10:39:13 ssdinarch spotifyd[39915]: No username specified. Checking username_cmd
set 17 10:39:13 ssdinarch spotifyd[39915]: No username_cmd specified
set 17 10:39:13 ssdinarch spotifyd[39915]: No password specified. Checking password_cmd
set 17 10:39:13 ssdinarch spotifyd[39915]: No password_cmd specified
set 17 10:39:13 ssdinarch spotifyd[39915]: No proxy specified
set 17 10:39:13 ssdinarch spotifyd[39915]: Using software volume controller.

Nothing shows up on devices list on web client, native client, android client.

It seems there is a missing part in documentation regarding zeroconf option. I've also tried without luck to set some port (4070, 4444) with --zeroconf-port option.

What is avahi? It's a service to broadcast something in the network?

@knuton
Copy link
Contributor

knuton commented Sep 19, 2021

I had the same or a similar issue and it turned out to be firewall related. Try setting a fixed zeroconf port in spotifyd and unblock it in your firewall.

Doing so made my spotifyd instance appear in a same-network iOS Spotify client, no need for credentials.

@jonkerj
Copy link
Author

jonkerj commented Sep 20, 2021

You are right, it simply works if you remove authentication options from the config. The machine I was testing on probably needs some tuning in the firewall. @klarkc: avahi is an open source "bonjour" implementation.

Lots of applications doing mdns-based auto-discovery typically leverage avahi. Spotifyd/librespot seem to work perfectly without avahi, so this was a wild goose.

@jonkerj jonkerj closed this as completed Sep 20, 2021
@jonkerj
Copy link
Author

jonkerj commented Sep 20, 2021

The plot thickens even more: the box on which I did not get spotifyd/zeroconf working has multiple interfaces, one of them being my ISP. The way librespot/libmdns works means that multicast replies follow kernel routing, so they were sent to my ISP (because the default route points there).

I'll work around this by adding a static route (yuck) for 224.0.0.251

@einarpersson
Copy link

I had the same or a similar issue and it turned out to be firewall related. Try setting a fixed zeroconf port in spotifyd and unblock it in your firewall.

Doing so made my spotifyd instance appear in a same-network iOS Spotify client, no need for credentials.

But what zeroconf port should be used? Whatever, as long as it is opened in the firewall?

For me it is working if I disable ufw completely but not when using 5353 in config and ufw

@eladyn
Copy link
Member

eladyn commented Nov 13, 2023

Okay, maybe some explanation on how the process works:
Spotifyd sets up a mdns responder (on 5353 UDP, so that needs to be open) and an HTTP server on a high random port (or zeroconf_port, if set - that is TCP). Through the MDNS responder, it advertises the HTTP server together with its port, so that it's irrelevant which port you enter as long as that one's free. (And connecting devices make a query to the HTTP server and supply an auth blob, but that is not that relevant.)

So to conclude, you need to open two ports:

  • 5353 UDP
  • zeroconf_port TCP. And any value above 1024 should be fine here, as long as it's not already taken.

Hope this helps.

@einarpersson
Copy link

Okay, maybe some explanation on how the process works: Spotifyd sets up a mdns responder (on 5353 UDP, so that needs to be open) and an HTTP server on a high random port (or zeroconf_port, if set - that is TCP). Through the MDNS responder, it advertises the HTTP server together with its port, so that it's irrelevant which port you enter as long as that one's free. (And connecting devices make a query to the HTTP server and supply an auth blob, but that is not that relevant.)

So to conclude, you need to open two ports:

  • 5353 UDP
  • zeroconf_port TCP. And any value above 1024 should be fine here, as long as it's not already taken.

Hope this helps.

This was exactly what I needed to understand. I would highly recommend adding this information that you just wrote to the documentation. Great explanation!

@eladyn
Copy link
Member

eladyn commented Nov 13, 2023

Thanks and good point, will do, when I get around to updating the documentation. (Currently it's lacking in some ways...)

knuton added a commit to knuton/spotifyd that referenced this issue Nov 13, 2023
Minimal docs that should point users with firewall issues in the right direction.

Based on personal discovery and the explanation in Spotifyd#998 (comment).
@knuton
Copy link
Contributor

knuton commented Nov 13, 2023

Thanks and good point, will do, when I get around to updating the documentation. (Currently it's lacking in some ways...)

Maybe a minimal addition like this will do for the meantime?

#1236

@einarpersson
Copy link

Thanks and good point, will do, when I get around to updating the documentation. (Currently it's lacking in some ways...)

Maybe a minimal addition like this will do for the meantime?

#1236

Perfect! Glad I could help, and excited to get spotifyd working :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature that would improve Spotifyd
Projects
None yet
Development

No branches or pull requests

6 participants