[GH-ISSUE #102] An unknown error occurred. #58

Closed
opened 2026-02-27 19:25:50 +03:00 by kerem · 2 comments
Owner

Originally created by @csimpi on GitHub (Oct 25, 2017).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/102

Hi, thanks for this awesome API!
I got a problem and I've tried to debug it without any luck.
I have a javascript that calls a function after any 5-10 sec randomly. That function gets data from Spotify API through my PHP file that uses your library.
It works well for hundred times without any issue, then I got this error message very randomly.

I use client credentials authentication, there is some problem with that part, as I can see.

Thx, Peter

The error message:

Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIException: An unknown error occurred. in /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php:44Stack trace:#0 /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php(222): SpotifyWebAPI\Request->parseBody(NULL, 502)#1 /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php(88): SpotifyWebAPI\Request->send('POST', 'https://account...', 'grant_type=clie...', Array)#2 /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Session.php(168): SpotifyWebAPI\Request->account('POST', '/api/token', Array, Array)#3 /var/www/mochart/public/api.php(84): SpotifyWebAPI\Session->requestCredentialsToken()#4 /var/www/mochart/public/api.php(34): spotiAuth('guest')#5 {main} thrown in /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php on line 44

Originally created by @csimpi on GitHub (Oct 25, 2017). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/102 Hi, thanks for this awesome API! I got a problem and I've tried to debug it without any luck. I have a javascript that calls a function after any 5-10 sec randomly. That function gets data from Spotify API through my PHP file that uses your library. It works well for hundred times without any issue, then I got this error message very randomly. I use client credentials authentication, there is some problem with that part, as I can see. Thx, Peter The error message: `Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIException: An unknown error occurred. in /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php:44Stack trace:#0 /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php(222): SpotifyWebAPI\Request->parseBody(NULL, 502)#1 /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php(88): SpotifyWebAPI\Request->send('POST', 'https://account...', 'grant_type=clie...', Array)#2 /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Session.php(168): SpotifyWebAPI\Request->account('POST', '/api/token', Array, Array)#3 /var/www/mochart/public/api.php(84): SpotifyWebAPI\Session->requestCredentialsToken()#4 /var/www/mochart/public/api.php(34): spotiAuth('guest')#5 {main} thrown in /var/www/mochart/public/vendor/jwilsson/spotify-web-api-php/src/Request.php on line 44`
kerem closed this issue 2026-02-27 19:25:50 +03:00
Author
Owner

@jwilsson commented on GitHub (Oct 27, 2017):

Hi!
It looks like Spotify is returning you a 502 Bad Gateway server error. I'd file an issue over at their repo and wrap your call to Session->requestCredentialsToken() in a try/catch where you retry the request and prevents it from crashing completely.

<!-- gh-comment-id:340011965 --> @jwilsson commented on GitHub (Oct 27, 2017): Hi! It looks like Spotify is returning you a `502 Bad Gateway` server error. I'd file an issue over at [their repo](https://github.com/spotify/web-api) and wrap your call to `Session->requestCredentialsToken()` in a `try/catch` where you retry the request and prevents it from crashing completely.
Author
Owner

@jwilsson commented on GitHub (Nov 3, 2017):

Closing this since I'm pretty sure it's an issue on Spotify's end. Just give me a shout if you want it reopened!

<!-- gh-comment-id:341827668 --> @jwilsson commented on GitHub (Nov 3, 2017): Closing this since I'm pretty sure it's an issue on Spotify's end. Just give me a shout if you want it reopened!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#58
No description provided.