I would like to make a non-blocking REST API call using PHP library GuzzleHttp.
- I have a REST API server (
http://api.example.com/v1/wait) waitmethod does not do anything, exceptsleep(10).- I am running the following from PHP CLI with
futureparam:
$client = new \GuzzleHttp\Client;
$response = $client->get('http://api.example.com/v1/wait', [
'future' => true,
'body' => [
'some' => 'var'
],
]);
echo 'OK';
I am expecting that "OK" would echo immediately, without waiting for completion of REST API call. Instead, the execution is suspended for 10 seconds - that is the sleep() duration in REST wait() method.
According to Guzzle documentation:
You can send asynchronous requests by setting the future request option to true
I am not interesting in call completion callbacks, all I want is to give API some (possibly, slow) task to work on and get on with life.
I have also tried cURL's own multirequest, several other libraries - the result is the same. Execution is blocked, waiting for response to arrive from API server.
So, what could be the problem?
Thanks!