mopidy-spotify icon indicating copy to clipboard operation
mopidy-spotify copied to clipboard

fail to login at startup

Open mczerski opened this issue 5 years ago • 5 comments

Hi, I'm using mopidy_spotify v4.0.1 on armbian buster on nano pi NEO SBC. I see there is an issue with spotify login when login fails on mopidy startup. For example, when there is no internet connection at mopidy startup and the internet connection comes back after couple of minutes spotify backend does not try to login again. To reproduce the issue, the connection must not come back until this log line appears:

ERROR [24188:SpotifyEventLoop] spotify.session: Spotify login error: <ErrorType.UNABLE_TO_CONTACT_SERVER: 8>

I have a solution but i'm not sure if this is correct, but at least it solves the problem for me:

diff --git a/mopidy_spotify/backend.py b/mopidy_spotify/backend.py
index 7cefb48..e4777dc 100644
--- a/mopidy_spotify/backend.py
+++ b/mopidy_spotify/backend.py
@@ -90,6 +90,16 @@ class SpotifyBackend(pykka.ThreadingActor, backend.Backend):
             self._logged_out,
             backend_actor_proxy,
         )
+        def logged_in(session, error_type):
+            if error_type is spotify.ErrorType.OK:
+                logger.error('Logged in as %s' % session.user)
+            else:
+                logger.error('Login failed: %s' % error_type)
+                session.login(
+                    self._config["spotify"]["username"],
+                    self._config["spotify"]["password"],
+                )
+        session.on(spotify.SessionEvent.LOGGED_IN, logged_in)
         session.on(
             spotify.SessionEvent.PLAY_TOKEN_LOST,
             on_play_token_lost,

mczerski avatar Jan 02 '21 23:01 mczerski

Looks like duplicate of #259

3nprob avatar Jun 16 '22 04:06 3nprob

See #110, Spotify turned down the library we used with one months notice...

adamcik avatar Jun 16 '22 05:06 adamcik

And the fix that is in flight shouldn't have the login issue you describe if I'm not mistaken.

adamcik avatar Jun 16 '22 05:06 adamcik

@adamcik The error here looks different from that (ie was still present before the ongoing, note it was reported in Jan)

3nprob avatar Jun 16 '22 05:06 3nprob

That's what I get for looking at this first thing in the morning :P

adamcik avatar Jun 16 '22 06:06 adamcik

libspotify has been removed, this issue won't occur in the latest version (but I fully expect one like it might so please reopen if so.

kingosticks avatar Mar 27 '23 15:03 kingosticks