[GH-ISSUE #203] SpotifyWebAPI\\SpotifyWebAPIException: Bad gateway. #140

Closed
opened 2026-02-27 19:26:16 +03:00 by kerem · 3 comments
Owner

Originally created by @wuzzy1212 on GitHub (Oct 2, 2020).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/203

This is a really finicky error, and wondering if anyone else has seen it, and how to deal with it.

For me, it's easily recreatable when flipping between the ios spotify app, and the web based browser application.

For instance, when initially authorizing the app either by desktop or spotify app I will be prompted by my
Screen Shot 2020-10-02 at 7 06 16 PM

Then, when opening the desktop spotify application and engaging it for a second, I will be promoted with
Screen Shot 2020-10-02 at 6 58 19 PM

If I use the play function for this device it will almost certainly work. Here's where it gets haywire. If I then open my phone and engage the app I will then get the green light that the phone app is ready to go and the desktop has now been deactivated. Which makes perfect sense.
Screen Shot 2020-10-02 at 6 59 31 PM

But, now, 99% of the time when I try to use the phone it will give me
PHP Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIException: Bad gateway

Its like spotify is holding some session that is different than my initial request from the desktop application. This as you can imagine is creating a beautiful mess for the user experience. Has anyone seen this, any steps you took to rectify it. Thanks for the wrap btw, other than this one issue this is flawless.

Also, when it does say "Bad Gateway" if I go over to the app in the phone, the song I was trying to get to start playing will actually start playing. So spotify did get the request they know the request but are not playing it until I open the app. How weird is this?

Originally created by @wuzzy1212 on GitHub (Oct 2, 2020). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/203 This is a really finicky error, and wondering if anyone else has seen it, and how to deal with it. For me, it's easily recreatable when flipping between the ios spotify app, and the web based browser application. For instance, when initially authorizing the app either by desktop or spotify app I will be prompted by my ![Screen Shot 2020-10-02 at 7 06 16 PM](https://user-images.githubusercontent.com/72274889/94955363-5e87a500-04e2-11eb-8feb-c8de27d42599.png) Then, when opening the desktop spotify application and engaging it for a second, I will be promoted with ![Screen Shot 2020-10-02 at 6 58 19 PM](https://user-images.githubusercontent.com/72274889/94954963-beca1700-04e1-11eb-9f37-d23e503d2ec7.png) If I use the play function for this device it will almost certainly work. Here's where it gets haywire. If I then open my phone and engage the app I will then get the green light that the phone app is ready to go and the desktop has now been deactivated. Which makes perfect sense. ![Screen Shot 2020-10-02 at 6 59 31 PM](https://user-images.githubusercontent.com/72274889/94955051-e8833e00-04e1-11eb-86ee-68c7d98a944f.png) But, now, 99% of the time when I try to use the phone it will give me PHP Fatal error: Uncaught SpotifyWebAPI\\SpotifyWebAPIException: Bad gateway Its like spotify is holding some session that is different than my initial request from the desktop application. This as you can imagine is creating a beautiful mess for the user experience. Has anyone seen this, any steps you took to rectify it. Thanks for the wrap btw, other than this one issue this is flawless. Also, when it does say "Bad Gateway" if I go over to the app in the phone, the song I was trying to get to start playing will actually start playing. So spotify did get the request they know the request but are not playing it until I open the app. How weird is this?
kerem 2026-02-27 19:26:16 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jwilsson commented on GitHub (Oct 3, 2020):

Hey!
That's indeed a really strange error, and I'm afraid I've never seen anything like it. I'd post a question on their developer forum and see if anyone there can help further.

I don't think it's an issue with this library because like you're saying, the song starts playing so Spotify should have received a valid request. But I'll leave this issue open for a while in case someone else has had a similar issue and will be able to help.

<!-- gh-comment-id:703061125 --> @jwilsson commented on GitHub (Oct 3, 2020): Hey! That's indeed a really strange error, and I'm afraid I've never seen anything like it. I'd post a question on their [developer forum](https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer) and see if anyone there can help further. I don't think it's an issue with this library because like you're saying, the song starts playing so Spotify should have received a valid request. But I'll leave this issue open for a while in case someone else has had a similar issue and will be able to help.
Author
Owner

@wuzzy1212 commented on GitHub (Oct 3, 2020):

Thanks, I appreciate that, and yes very strange!

<!-- gh-comment-id:703067945 --> @wuzzy1212 commented on GitHub (Oct 3, 2020): Thanks, I appreciate that, and yes very strange!
Author
Owner

@wuzzy1212 commented on GitHub (Oct 3, 2020):

I'm able to get past this issue by making a non related call before trying to play the song

try {
$api->getMyCurrentPlaybackInfo();
$api->play($spotify_id, [
'uris' => ['https://open.spotify.com/track/5dRQUolXAVX3BbCiIxmSsf'],
]);

} catch (SpotifyWebAPI\SpotifyWebAPIException $e) {

$reason = $e->getReason();

}

Interesting.

Update: Nevermind, that does not work.

<!-- gh-comment-id:703079497 --> @wuzzy1212 commented on GitHub (Oct 3, 2020): I'm able to get past this issue by making a non related call before trying to play the song try { $api->getMyCurrentPlaybackInfo(); $api->play($spotify_id, [ 'uris' => ['https://open.spotify.com/track/5dRQUolXAVX3BbCiIxmSsf'], ]); } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { $reason = $e->getReason(); } Interesting. Update: Nevermind, that does not work.
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#140
No description provided.