yii2-httpclient
yii2-httpclient copied to clipboard
How to catch exceptions in bulk request sending?
What steps will reproduce the problem?
In bulk request sending, when a request fails, the response cannot be obtained. When one request fails, how do other requests return correctly?
use yii\httpclient\Client;
$client = new Client();
$requests = [
$client->get('http://domain.com/keep-alive'),
$client->post('http://domain.com/notify', ['userId' => 12]),
];
$responses = $client->batchSend($requests);
What's expected?
In batch requests, not only some requests fail, but also other requests return correctly
What do you get instead?
If there is a request timeout in batch request sending, an exception is responded
Additional info
Q | A |
---|---|
Yii version | 2.0.35 |
Yii HTTP Client version | ^2.0 |
PHP version | 7.1.31 |
Operating system | CentOS7.6 |