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

fail to login at startup #296

Closed
mczerski opened this issue Jan 2, 2021 · 6 comments
Closed

fail to login at startup #296

mczerski opened this issue Jan 2, 2021 · 6 comments
Labels
A-libspotify Area: libspotify

Comments

@mczerski
Copy link

mczerski commented Jan 2, 2021

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,
@3nprob
Copy link
Contributor

3nprob commented Jun 16, 2022

Looks like duplicate of #259

@adamcik
Copy link
Member

adamcik commented Jun 16, 2022

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

@adamcik adamcik closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2022
@adamcik
Copy link
Member

adamcik commented Jun 16, 2022

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

@3nprob
Copy link
Contributor

3nprob commented Jun 16, 2022

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

@adamcik adamcik reopened this Jun 16, 2022
@adamcik
Copy link
Member

adamcik commented Jun 16, 2022

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

@kingosticks
Copy link
Member

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 kingosticks closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2023
@kingosticks kingosticks added the A-libspotify Area: libspotify label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-libspotify Area: libspotify
Projects
None yet
Development

No branches or pull requests

4 participants