Announcements

Help Wizard

Step 1

NEXT STEP

iOS & Android Remote SDK loses connection after paused for 30s or more

iOS & Android Remote SDK loses connection after paused for 30s or more

Plan

Premium

Country

NZ

Operating System

iOS & Android (all supported models)

 

My Question or Issue

We are developing an app targeting practicing musicians and are attempting to use your remote SDK's for iOS and Android as the method of communication between our app and the local Spotify instance on the device. We have encountered that there seems to be a ~30s period of grace after pausing a track where the connection remains between the SDK and Spotify, but if no track is played during this window, the Spotify App ends its connection with the SDK. 
Is there a way to prevent this happening outside of playing a snippet of a song every 25s, or swapping to the Playback API? 

Reply
5 Replies

Hey, how are you? Welcome to the Spotify Community.

 

The behavior you described is expected and indirectly documented. This timeout exists to conserve system resources and avoid unnecessary connections to Spotify, especially when the app is in the background.

 

However, I can suggest some alternatives:

 

1. Combine Remote SDK + Web API

Use the Remote SDK while the session is active (for real-time control).

When the session ends, use the Web API to query the status and resume the connection as soon as a new playback begins.

Note: The Web API has update limits (usually 1 call per second).

 

2. Disconnection Detection + Automatic Reconnection
Configure your app to detect SDK disconnection and attempt to automatically reconnect as soon as the user interacts with Spotify again.

 

3. Monitor PlayerState
You can configure the playerState listener to monitor changes and proactively attempt to reconnect as soon as something is detected (e.g., the user presses "play").

 

⚠️ I also have some important caveats:

Spotify does not allow you to maintain a passive connection indefinitely with the Remote SDK.

Any attempt to bypass the timeout without real interaction may be considered a violation of the platform's best practices.

 

If you'd like, I can continue helping you! Let me know which programming language you're using and we can come up with an alternative together 🙂

 

Cheers,
ribezaz

ribezazSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Hi ribezaz, thank you for your feedback!

I have just attempted implementing the API + SDK connection but unfortunately I cannot get it to maintain the connection with the SDK as it appears to just keep the connection to Spotify's server open, but not the connection to the app itself. The main thing we are trying to prevent is the 30s shutoff period for the SDK, as we have already implemented your other suggestions and while we can reconnect just fine, it requires the Spotify App switching into the foreground briefly, which isn't quite ideal.

The app is being developed in flutter.

Hi ribezaz,
Would love to do it the way you suggested with using web api. But how do we pass the auth token we get from the web api to the iOS sdk to pickup the connection? Switching between apps every time the user opens it isn't the optimal. Thank you for any help!

Hello @maxadams ! I understand the scenario better. Thanks for explaining. And I apologize for the delay!

 

Indeed, this behavior (automatic termination of the Remote SDK session after about 30 seconds of no playback) is part of the SDK's design and cannot be disabled by developers. The session requires the Spotify app to be active to maintain direct communication, which is why it times out when in the background or not playing.

 

Unfortunately, there is no official solution to maintain the connection indefinitely. What you can do is:

 

Proactive reconnection:
Continue with the strategy of automatically reconnecting whenever the user interacts again. This is what Spotify recommends as a best practice.

 

Web API as a fallback:
While the local SDK session is inactive, use the Web API to monitor the playback status. This way, you maintain up-to-date information (albeit less frequently) until the SDK can reconnect.

 

Alternative UX:
Since the app is in Flutter, it might be helpful to consider a UI flow that clearly communicates to the user that "real-time control requires Spotify to be active in the foreground"—this avoids frustration and provides clarity about the technical limitation.

 

Currently, there is no supported way to prevent the SDK from automatically shutting down without playback—any workaround that attempts to "force activity" (such as looping snippets) may violate the platform guidelines.

 

If it helps, I can share examples of how to detect the Remote SDK's disconnected event on native Android/iOS and map this to Flutter, automating the fallback to the Web API without the user needing to notice the transition.

ribezazSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Hello @wallinex !

 

Great question! From what I've researched, the main point is that the Remote SDK doesn't authenticate itself—it relies on you providing a valid access token to initiate the connection.

 

This means you can use the same token you obtained via OAuth from the Web API for the SDK, as long as:

 

1. The token was requested with the app-remote-control scope (and usually also user-modify-playback-state, if you want to control playback).

2. The token is still valid (not expired).

3. The token is passed directly to the SDK when you open the connection.

 

In other words, you don't need to open a login screen every time. Simply use the same OAuth flow you already implemented for the Web API and reuse the resulting access token.

 

⚠️ Important:

Web API tokens expire in 1 hour. Therefore, you also need to implement the token refresh flow to ensure you always have a valid token to provide to the SDK.

 

Even using this shared token, the Remote SDK will continue to follow the timeout rule (about 30 seconds without playback). This behavior is part of Spotify's design and cannot be changed.

 

Keep me updated so I can continue helping you!

 

Cheers,
ribezaz

ribezazSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random