Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Web API 502 error on /me/player/play for a short period after track end

Web API 502 error on /me/player/play for a short period after track end

I am currently building a web application that uses the spotify web API and the web playback SDK. Part of this application is a frontend-side playlist (not spotify playlists). For this I react on 'player_state_changed' events to play the next track in my playlist when the current track ends.

However, when I do this, I always get 502 errors, with no further information (
error Object { status: 502, message: "Bad gateway." })

 

If I manually execute the exact same call a few seconds later, or include a sleep in my code, the call works. If I check the device status directly before the call, I cannot detect any restrictions.

The API seems to be unable to answer calls for a short moment when a track has ended.

Reply
3 Replies

Dealing with the same problem, there is a way to detect a "ready for request" player?

It has increasingly been an issue, even for my home-grown app with a reasonable amount of API calls. I even implemented a retry feature that only shows a user anything after X attempts, but it still pops up. At one point, the playlist endpoint was entirely unresponsive. I didn’t notice if this coincided with a track ending, but it’s something I’ll keep in mind. 

I do hope they fix these intermittent issues, as it’s a bummer to spend all that time designing a player around the API and then it turns flaky. 

I was able to workaround this issue by adding a small delay before calling the /me/player/play endpoint. I'm using React so when I determine that a song has ended with the player_state_changed object I set a boolean that will trigger a setInterval to run with a 500ms delay and its callback is my function that will send the request to Spotify Web API.

Suggested posts

Type a product name