drouning
drouning

Reputation: 385

Guzzlehttp error when opening stream

In Laravel i made a command with this code in handle() using the Leaguewrap library:

$api = new Api($_ENV['RIOT_KEY']);
$staticData = $api->staticData();
$realmdata = $staticData->getRealm();

When i try to run this command i get the following error:

[GuzzleHttp\Exception\RequestException] Error creating resource: [message] fopen(https://global.api.pvp.net/api/lol/static-data/na/v1.2/realm?api_key=xxx): failed to open stream: Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat. [file] \vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php [line] 244

[RuntimeException] Error creating resource: [message] fopen(https://global.api.pvp.net/api/lol/static-data/na/v1.2/realm?api_key=xxx): failed to open stream: Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat. [file] \vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php [line] 244

Which i don't understand because when i copy the exact URL and open it in a browser it works:

{"css":"5.23.1","dd":"5.23.1","l":"en_US","n":{"item":"5.23.1","rune":"5.23.1","mastery":"5.23.1","summoner":"5.23.1","champion":"5.23.1","profileicon":"5.23.1","map":"5.23.1","language":"5.23.1"},"profileiconmax":28,"v":"5.23.1","lg":"5.23.1","cdn":"http://ddragon.leagueoflegends.com/cdn"}

Any ideas on how to solve this problem?

Upvotes: 3

Views: 4462

Answers (1)

drouning
drouning

Reputation: 385

The problem can occur when you are running it within Vagrant or docker. Here, I was using Laravel Homestead and ran the command outside of the vagrant box.

Using SSH to connect to the machine and running the command inside works fine.

Upvotes: 1

Related Questions