Spotify login error: <ErrorType.UNABLE_TO_CONTACT_SERVER: 8>

Excellent work. It looks like Spotify don’t maintain ap.spotify.com reliably (deprecated? Incompetence?) and have moved to using apresolve.spotify.com but libspotify of course never got this update.

There might be a way we can patch libspotify or perhaps have it connect through a proxy that handles this.

My understanding is that libspotify is deprecated, and that is why it has not been updated. Spotify had promised to come out with a replacement for the library but never delivered on that promise.

There might be a way we can patch libspotify or perhaps have it connect through a proxy that handles this.

$ strings /usr/lib/libspotify.so | grep ap.spotify.com
https://ap.spotify.com

It seems that ap.spotify.com is a hardcoded string in the library.

If apresolve.spotify.com provides the same interface then fixing the library should be as simple as patching the value of that string in the binary (and adjusting any ELF offsets that may change in the process).

However, if they have also changed the request/response format then that may be a bit too much for a weekend reversing task…

Thanks, this manual host entry for 104.154.126.229, is the quick temporary fix for me.

None of the A Records I grabbed from dig -type A ap.spotify.com is pingable…

;; ANSWER SECTION:

ap.spotify.com. 187 IN CNAME ap.gslb.spotify.com.
ap.gslb.spotify.com. 299 IN A 104.199.64.33
ap.gslb.spotify.com. 299 IN A 35.190.242.76
ap.gslb.spotify.com. 299 IN A 104.199.65.207
ap.gslb.spotify.com. 299 IN A 104.199.64.43
ap.gslb.spotify.com. 299 IN A 35.190.243.130
ap.gslb.spotify.com. 299 IN A 104.199.65.52
ap.gslb.spotify.com. 299 IN A 35.190.243.110
ap.gslb.spotify.com. 299 IN A 35.190.242.183

Sadly it does not provide the same interface. You send an HTTP request to apresolve.spotify.com and it provides you with a json response containing a list of access points you can use. So it is more work.

EDIT:

But you should be able to manually take one of the results from apresolve and stick that in your /etc/hosts file. If someone could test that out that would be nice.

this is the access point list I get from apresolve.spotify.com. Which port does libspotify use?

{

   "ap_list":[
      "gew1-accesspoint-a-3lcg.ap.spotify.com:4070",
      "gew1-accesspoint-a-m300.ap.spotify.com:443",
      "gew1-accesspoint-a-qd60.ap.spotify.com:80",
      "gew1-accesspoint-a-6tzj.ap.spotify.com:4070",
      "gew1-accesspoint-a-tzhz.ap.spotify.com:443",
      "gew1-accesspoint-a-cr9c.ap.spotify.com:80",
      "guc3-accesspoint-a-bxrg.ap.spotify.com:4070",
      "guc3-accesspoint-a-sfsl.ap.spotify.com:443",
      "guc3-accesspoint-a-k6j7.ap.spotify.com:80"
   ]
}

Fixed with gew1-accesspoint-a-qd60.ap.spotify.com (104.199.65.34) !

1 Like

I believe that it uses all 3 from the strace logs I have seen.

After doing some digging it seems that Spotify may be trying to phase out non Spotify connect playback even on commercially made devices. Savant, a home automation platform that is typically a real stickler for keeping users in their own app, for everything has removed Spotify from their app in favor of Spotify connect in their 9.4 update.

Try rather if port 443 is opened.
as.spotify.com is pingable, but it is not enough.

Regards!

I suppose yes, as it is working nice now.

@kingosticks I have done a bit of research these days into Librespot and the Spotify player APIs. It should be possible to write a backend that uses Librespot to advertise the device to Spotify Connect and stream content, and use the Spotify Connect API or the player API to queue tracks and manage playback. And since Librespot already supports gstreamer as a backend it hopefully shouldn’t be too much work to fit it into mopidy’s audio system.

I know it requires quite a big rewrite of the extension, but it may be the best way forward to be future-proof (it sounds to me like we are at the mercy of Spotify when it comes to the support for ap.spotify.com).

If it sounds like a reasonable option I can work on a PoC in the upcoming days.

2 Likes

Connect is an orthogonal problem. I don’t believe the player API is useful for our needs but maybe I misunderstand.

Unfortunately we are always at the mercy of Spotify. They have previously revoked our Web API access, despite always sticking to their usage restrictions, and it was quite an effort to find someone who had their head sufficiently screwed on to sort that out. libspotify may continue to rot (although considering it still (mostly) works I expect they are stuck supporting some big customer). I’ve requested their promised libspotify replacement for years through all sorts of channels, I am not hopefull but might as well keep asking. They are constantly changing their official client to stay tech-fashionable and librespot will always be an exercise in playing catch-up. Pick your poison!

I will warn you that all the librespot backends are rough around the edges and the GStreamer one is very rough. I’d go as far to say nothing about that backend is usable for us. I think we would either do somethnig similar to what we have now with appsrc or, better yet, write a proper GST source. I don’t think librespot currently exposes the correct APIs to do this (last time I checked was before librespot-org took over but I don’t think this has changed since).

A problem with librespot is that it wants to be a library but it’s still more of a proof of concept application and the exposed APIs are lacking. But the good news is that it has recently seen some active development towards supporting Spotify’s latest protocols (always playing catch-up!) and once that’s done hopefully their API will become more stable and we can request anything more we need to start building on it. I think it would be a lot of work but really interesting - honestly I wish I had the time.

It is definitely not my intention here to discourage you and these are just my personal thoughts on the current status. If you want to take a closer look now and knock-up a librespot PoC then please do. And if you want to discuss this further maybe do so at https://github.com/mopidy/mopidy-spotify/issues/110. Please take a read through all of that if you haven’t already seen it.

In the meantime I think a disgusting hack using libspotify’s proxy support might provide a quick and more self-contained work-around. Someone could also look at that.

1 Like

It’s pretty amazing it’s working at all, considering the latest release was 2012 or something. It must be that other people are using it.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.