spotify_sdk
spotify_sdk copied to clipboard
connectToSpotifyRemote fails when providing access token
Describe the bug SpotifySdk.connectToSpotifyRemote fails to connect to spotify and throws several errors when I provide an access token. I know the token is valid as I just got it from a request under an hour ago. When I call connectToSpotifyRemote in the exact same place without an access token it works just fine.
To Reproduce Steps to reproduce the behavior:
- call SpotifySdk.connectToSpotifyRemote and provide accessToken argument.
Expected behavior SpotifySdk to let me reuse my access token.
Smartphone (please complete the following information):
- Device: Iphone 8
- OS: ios 14
@dhcracchiolo I can't reproduce your issue. Which version of the package are you using? Try using the latest from master. Would also be nice if you could provide some code that demonstrates the issue.
Hey I have the same problem. When i try to connect with a token i got only a few minutes before i get the following error:
AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x280d90150 {Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSLocalizedRecoverySuggestion=Reconnect the transport to the Spotify app., NSLocalizedFailureReason=A stream error has occured in the transport.}
Hey I have the same problem. When i try to connect with a token i got only a few minutes before i get the following error:
AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x280d90150 {Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSLocalizedRecoverySuggestion=Reconnect the transport to the Spotify app., NSLocalizedFailureReason=A stream error has occured in the transport.}
what you are facing is most likely a native SDK issue. Does restarting the Spotify app fix the issue?
Closing due to lack of feedback. If the issue persists please report back.
I'm having the same problem, basically If I get the access token using my api calls on the backend, instead of using your method, I can't pass the access token to "connectToSpotifyRemote" because it throws that error. And so I can't connect silently.
Hey I have the same problem. When i try to connect with a token i got only a few minutes before i get the following error:
AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x280d90150 {Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSLocalizedRecoverySuggestion=Reconnect the transport to the Spotify app., NSLocalizedFailureReason=A stream error has occured in the transport.}
what you are facing is most likely a native SDK issue. Does restarting the Spotify app fix the issue?
I'm also getting this error. Yes, restarting the spotify app fixes the issue. If I call SpotifySdk.getAccessToken
, i redirect to the app again, and i am able to connectToSpotifyRemote
again. After waiting about 30 seconds of not using the SDK, I get the following error:
AppRemote: Disconnected with error: Error Domain=com.spotify.app-remote.transport Code=-2001 "End of stream." UserInfo={NSLocalizedRecoverySuggestion=Reconnect to the Spotify app., NSLocalizedDescription=End of stream., NSLocalizedFailureReason=One of the streams has reached the end.}
any attempt to use SpotifySdk.connectToSpotifyRemote
using the same access token at this point returns the following error:
AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x28096c6c0 {Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSLocalizedRecoverySuggestion=Reconnect the transport to the Spotify app., NSLocalizedFailureReason=A stream error has occured in the transport.}
Any update 2024? Library a little abandoned?
Did anyone ever verify that the same issue does not happen with the native iOS SDK? Until this is crosschecked and verified this cannot be considered an issue with this library. Ideally someone should submit both:
- A minimal Flutter project that reproduces the issue
- A minimal native iOS project that does not have the issue, using the same Spotify credentials, bundle id etc.
have the same issue,
steps to reproduce:
-
got an access token(save it, we will need it in the end)
-
press pause, wait 10-30 sec and get the error:
AppRemote: Disconnected with error: Error Domain=com.spotify.app-remote.transport Code=-2001 "End of stream." UserInfo={NSLocalizedRecoverySuggestion=Reconnect to the Spotify app., NSLocalizedDescription=End of stream., NSLocalizedFailureReason=One of the streams has reached the end.}
-
trying connectToSpotifyRemote with the same token and i get:
AppRemote: Connecting...
[] nw_path_necp_check_for_updates Failed to copy updated result (22)
[connection] nw_socket_handle_socket_event [C25.1.1:1] Socket SO_ERROR [61: Connection refused]
[connection] nw_socket_handle_socket_event [C25.1.2:1] Socket SO_ERROR [61: Connection refused]
[connection] nw_connection_get_connected_socket_block_invoke [C25] Client called nw_connection_get_connected_socket on unconnected nw_connection
TCP Conn 0x283dfc500 Failed : error 0:61 [61]
AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x2802c6190 {Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSLocalizedRecoverySuggestion=Reconnect the transport to the Spotify app., NSLocalizedFailureReason=A stream error has occured in the transport.}
flutter: \^[[38;5;196m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;196m│ #0 SpotifySdk._logException (package:spotify_sdk/spotify_sdk.dart:669:15)<…>
flutter: \^[[38;5;196m│ #1 SpotifySdk.connectToSpotifyRemote (package:spotify_sdk/spotify_sdk.dart:94:7)<…>
flutter: \^[[38;5;196m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;196m│ ⛔ connectToSpotify failed with: Connection attempt failed.<…>
flutter: \^[[38;5;196m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;12m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;12m│ #0 HomeState.setStatus (package:slide/features/spotify/presentation/pages/spotify_example_page.dart:669:13)<…>
flutter: \^[[38;5;12m│ #1 HomeState.connectToSpotifyRemote (package:slide/features/spotify/presentation/pages/spotify_example_page.dart:457:7)<…>
flutter: \^[[38;5;12m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;12m│ 09:58:18.866 (+0:07:30.158053)<…>
flutter: \^[[38;5;12m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;12m│ 💡 -1000Connection attempt failed.<…>
flutter: \^[[38;5;12m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
However, if I use getAccessToken after the last error, disconnect, and then connectToSpotifyRemote with my previously saved access token on the first step, then it works. If you press pause again and wait for 10-30 seconds, it will disconnect with an error message again.
UPDATE: i found something here, they have the same issue, but its native iOS https://stackoverflow.com/questions/60060661/spotify-appremote-is-not-reconnecting-once-disconnected-in-ios