php - How do you deal with rejected responses in guzzel? -
consider following code:
public function getitemhistoryforregion(array $items, array $regions) { $client = new client(['expect' => false]); $acceptedresponses = []; $rejectedresponses = []; $createdrequests = []; $regionanditem = []; foreach($items $item) { foreach ($regions $region) { array_push($regionanditem, [$item, $region]); array_push($createdrequests, new request('get', 'https://public-crest.eveonline.com/market/'.$region.'/types/'.$item.'/history/')); } } $pool = new pool($client, $createdrequests, [ 'concurrency' => 10, 'fulfilled' => function ($response, $index) use (&$acceptedresponses) { eveloghandler::requestlog($response, 'eve_online_region_item_history_responses.log'); $acceptedresponses[$index] = json_decode($response->getbody()->getcontents()); }, 'rejected' => function ($reason, $index) use(&$rejectedresponses) { eveloghandler::messagelog($reason, 'eve_online_region_item_history_rejected_responses.log'); }, ]); $promise = $pool->promise(); $promise->wait(); $historydetails = new historydetails($acceptedresponses, $regionanditem); $historydetails->createhistorydetails(); return $historydetails->gethistorydetails(); }
i create array of requests pooled. there 10,000 requests come through here.
one of issues rejected section:
'rejected' => function ($reason, $index) use(&$rejectedresponses) { eveloghandler::messagelog($reason, 'eve_online_region_item_history_rejected_responses.log'); },
here log out rejected message , comes as:
[2016-01-27 16:35:00] production.info: message ["[object] (guzzlehttp\\exception\\connectexception(code: 0): curl error 52: empty reply server (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) @ /home/ccccc/test_site/vendor/guzzlehttp/guzzle/src/handler/curlfactory.php:186)"] [] [2016-01-27 16:35:57] production.info: message ["[object] (guzzlehttp\\exception\\connectexception(code: 0): curl error 52: empty reply server (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) @ /home/ccccc/test_site/vendor/guzzlehttp/guzzle/src/handler/curlfactory.php:186)"] []
theres ton of these there on 13 jobs queued each send 10,000 requests each, can see pool them 10 @ time.
the rate limit api 150 requests per second. know not hitting 150 or @ least shouldn't be.
the question have how re-try rejected request? there way say, on fail retry max of x times? guzzle have built in?
the curl error receiving might indication of server / proxy / firewall rate limiting you; if application throwing 10k requests @ it. error (at least according libcurl indicates application not receiving response.
i believe looking either "retry middleware" or "rate limiting middleware"
Comments
Post a Comment