fix: try multiple times to connect to an AP#87
Merged
devgianlu merged 1 commit intodevgianlu:masterfrom Sep 10, 2024
Merged
Conversation
I sometimes get "connection refused" for no apparent reason, even though the same AP works at other times. So when that happens, try again with a different AP. I don't know why this happens, but with this patch the connection code should be a bit more robust.
devgianlu
reviewed
Sep 10, 2024
| for { | ||
| attempts++ | ||
| ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) | ||
| defer cancel() |
Owner
There was a problem hiding this comment.
This defer will trigger only when returning from the function therefore we might have up to 6 contexts running simultaneosly. This shouldn't be an issue, just saying.
devgianlu
reviewed
Sep 10, 2024
| return fmt.Errorf("failed to connect to AP %v: %e", addr, err) | ||
| } | ||
| // Try again with a different AP. | ||
| log.Warnf("failed to connect to AP %v (error: %v), retrying with a different AP", addr, err) |
Owner
There was a problem hiding this comment.
You could use .WithError() error here, but also just a note.
Owner
|
This seems to be an issue with Spotify infrastructure. It has been reported by many users: https://community.volumio.com/t/new-2023-spotify-plugin/63381/378 Since this is a bit urgent I am merging anyway, feel free to open another PR to take care of the comments above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I sometimes get "connection refused" for no apparent reason, even though the same AP works at other times. So when that happens, try again with a different AP.
I don't know why this happens, but with this patch the connecting code is a bit more robust. I've verified that it works: it connects to the next in the list which usually works.