Reputation: 13537
I am calling an endpoint that returns a lot of "datapoints" which are then plotted on a graph. It works great when I ask for 45 days of data, but the moment I go over it, I get a blank result.
I call it like this:
$client = new GuzzleHttp\Client();
$client->setDefaultOption('verify', false);
$result = $client->get($url.'/v2/device/1/datapoint/'.$startDateString.'/'.$endDateString.'/?api_key='.$APIKEY,
['auth' => [$username, $password]],
array(
'timeout' => 500,
'connect_timeout' => 500
)
);
As you can see, my timeouts are massive. Which leads me to believe there might be some other limit being hit. Like, for example, not allowing a response bigger than a certain size.
But I can't find a way to set this using guzzle? Any idea if this could be the problem or perhaps something else?
Upvotes: 0
Views: 1339
Reputation: 7975
Guzzle will probably throw an exception if anything goes wrong, so have you check that the server is replying correctly when you ask for lots of data?
Otherwise its not unlikely that your script is crashing because of the memory limit, checking the php error log should help to see if this is the case.
If that is the problem there are different way of dealing with it, depending on the data and what you want to do with it.
Guzzle supports giving you a stream of data, this means it doesn't load the whole data into memory, but can give you it one chunk at a time.
Alternatively you might want to make several smaller requests to your server and combine the results.
Upvotes: 1