ios-sdk icon indicating copy to clipboard operation
ios-sdk copied to clipboard

Connection Errors on Initializing Spotify on iOS.

Open dglaser2 opened this issue 5 years ago • 3 comments

I have been struggling with implementing the Spotify iOS SDK in a simple music player app that I’m working on with the intention of learning more about the streaming platform’s API. My app’s features are storyboard-based and have simple functionality (i.e. connect/disconnect, pause/play, fast forward/rewind, fetch album artwork)

I modeled my authorization method off of the demo project SPTLoginSampleAppSwift, and have been trying to troubleshoot the errors I’m getting (I’ll paste them below).

After a few weeks of struggling with this API, I decided to run the demo project on my device and realized that it does not seem to function properly either. Does anyone know how I can fix these errors and successfully initiate Spotify functionality in my app? I’m quite frustrated and would really appreciate any advice. I'm including my Github Repo below as well.

https://github.com/dglaser2/SpotifyPlayer

ERRORS:

Upon clicking connect: -canOpenURL: failed for URL: "spotify:" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

Upon returning to app after authorization screen:

2021-01-07 16:59:16.775788-0500 SpotifyPlayer[39554:3692500] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2021-01-07 16:59:16.907970-0500 SpotifyPlayer[39554:3688560] AppRemote: Connecting...
2021-01-07 16:59:16.921229-0500 SpotifyPlayer[39554:3692500] [connection] nw_socket_handle_socket_event [C2.1:1] Socket SO_ERROR [61: Connection refused]
2021-01-07 16:59:16.923633-0500 SpotifyPlayer[39554:3692500] [connection] nw_socket_handle_socket_event [C2.2:1] Socket SO_ERROR [61: Connection refused]
2021-01-07 16:59:16.926122-0500 SpotifyPlayer[39554:3691493] [connection] nw_connection_get_connected_socket [C2] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-01-07 16:59:16.926941-0500 SpotifyPlayer[39554:3691493] TCP Conn 0x600002b6c0b0 Failed : error 0:61 [61]
2021-01-07 16:59:16.928526-0500 SpotifyPlayer[39554:3688560] AppRemote: Failed connection attempt with error: Error Domain=com.spotify.app-remote.transport Code=-2000 "Stream error." UserInfo={NSLocalizedDescription=Stream error., NSUnderlyingError=0x600001228f00 {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.}

dglaser2 avatar Jan 07 '21 22:01 dglaser2

I've been getting the same errors intermittently and have not found a good way around it. Currently I'm signaling that Spotify is disconnected in the UI and then using authorizeAndPlayURI to resume. This is annoying because it goes through auth flow more than I think is needed.

I've noticed that this usually only happens when Spotify is paused. I'm assuming iOS backgrounds Spotify which in turn causes these connection errors. It doesn't only happen when Spotify is paused though - I've experienced it mid-stream too.

Would love some clarification/solutions to this as well.

pmilla1606 avatar Jan 10 '21 13:01 pmilla1606

Also running into this error as well. The SDK appears to be broken frankly. For anyone else reading this and looking for a potential solution, I decided to bypass using the SDK and I instead authenticate with a separate backend (Node and Express in my case).

It's annoying to have to deploy a separate service for something that should easily work on the device itself but unfortunately such is our fate.

roz0n avatar Mar 21 '21 07:03 roz0n

We've run into a similar problem. Right now, we are pretty sure that this will make the Spotify SDK not usable for us as a means to playback songs.

tonykarrer avatar Mar 21 '21 13:03 tonykarrer