2

Does anyone know how to send a working and non-blocking async request using guzzlephp?

There seems to be a support for this but it does not seem to be implemented

<?php

$this->guzzle->requestAsync('post', 'http://', ['synchronous' => false])->wait();

?>

Implemented in a sense that it does not wait for the response.

There is also a problem with php-ga-measurement-protocol

$analytics->setAsyncRequest(true)->sendPageview(); 
OldPadawan
  • 1,247
  • 3
  • 16
  • 25

1 Answers1

0

What problem you are talking about?

Async requests work fine in Guzzle, exactly as you described. You just get a promise from requestAsync() immediately, do other stuff and take the response, when you are ready.

// ['synchronous' => false] is not required.
$responsePromise = $this->guzzle->requestAsync('post', 'http://...');

// Your stuff...

$response = $responsePromise->wait();

Don't know about php-ga-measurement-protocol, BTW, but seems that this lib implements them correctly too.

Alexey Shokov
  • 4,775
  • 1
  • 21
  • 22