mirror of
https://github.com/jwilsson/spotify-web-api-php.git
synced 2026-04-27 07:55:49 +03:00
[GH-ISSUE #279] Dealing with Spotify server not responding exception #206
Labels
No labels
bug
docs
enhancement
enhancement
enhancement
feedback wanted
good first issue
help wanted
help wanted
help wanted
invalid
pull-request
question
question
upstream
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotify-web-api-php#206
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @upgrader-dev on GitHub (Nov 22, 2024).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/279
Hello guys,
My app is currently in dev mode under my developer.spotify account.
Sometimes it happens that Spotify'servers no more respond to my requests, I guess that may be because I get out of my quota.
This kind of exception is not caught by SpotifyWebApiException because it is not :)
Have a look at the screen shot.

So I'm wondering... How do you guys deal with such exceptions?
My first thought was to wrap every request to SpotifyWebAPI in a try catch but wouldn't it be easier that the wrapper itself deals with this kind of exception?
More a discussion than an issue, but didn't find any discussion tab here.
Thank you for your help.
@jwilsson commented on GitHub (Nov 28, 2024):
Hello!
I don't think the API will just timeout if you hit your quota, it should reply with a HTTP 429 error which you can have the library automatically retry.
I'm a bit confused if that's actually the error though or if it's something else causing your script to exceed the 30 second limit, you could try setting the cURL timeout to a lower value and see if the same issue occurs.
Because I'm not sure what the library would do with any timeout errors otherwise either, I think the thing that would make the most sense in that case it to just re-throw the error which would still need to be handled by the calling code.
@upgrader-dev commented on GitHub (Dec 29, 2024):
Hello,
In fact I never get any 429 response in many month of work. But sometimes When I get a lot if users on my app this behavior happens. That’s why I end up thinking that the API never sends the 429 response while stated in the documentation. That wouldn’t be the first behavior being note like in the docs :)
Did you already get any 429?
I read carefully the end of your answer below but can’t understand why lowering the timeout limit may be useful.
I’ll try to get this error reproduced and if needed I’ll update this subject :)
Thank you
Benjamin
@jwilsson commented on GitHub (Jan 13, 2025):
Hmm, that sounds strange though 🤔
But my thinking with lowering the request timeout was due to the error message in your screenshot, the PHP execution limit is reached which isn't something library can do much about.
@upgrader-dev commented on GitHub (Apr 6, 2025):
Got a new happen of this behaviour today.
_Fatal error: Maximum execution time of 30 seconds exceeded in /app/vendor/jwilsson/spotify-web-api-php/src/Request.php on line 225
Warning: Cannot modify header information - headers already sent by (output started at /app/vendor/jwilsson/spotify-web-api-php/src/Request.php:225) in /app/vendor/symfony/http-foundation/Session/SessionUtils.php on line 52_
Wouldn't this exception be caught by your code? Or Do I have to catch it? Personnaly I would initially believe it would throw a SpotifyWebAPIException.
@jwilsson commented on GitHub (Apr 11, 2025):
It seems the Spotify API is taking too long to respond so the server is killing the PHP process. This isn't something the library can (or should) handle.
I'd limit the request timeout so the request will fail with an expected
SpotifyWebAPIExceptionbefore 30 seconds has elapsed and the server kills it. There's some docs on how to accomplish that here.