Not sure if this is an environment issue or it's a bug of laravel, I tried sending Http requests back to back using Http client, but got ConnectionException when sending certain amount (around 80 times) of Http requests. I have the code to reproduce the issue below, it is working fine in 8.36.0 but not the newer versions. It seems the issue is related to the new added concurrent async request feature.
Anyone have an idea what would be the cause? or help on reproducing it so that I can confirm it's a bug but not caused by my environment? Thanks!
Code to reproduce the issue
try {
foreach (range(0, 200) as $number) {
dump($number);
// adding sleep doesn't seem to have any impact
usleep(100000);
Http::get('https://example.com');
}
}catch (\Exception $ex) {
dump($ex);
}
Exception:
Illuminate\Http\Client\ConnectionException^ {#7605
#message: "cURL error 6: Could not resolve host: example.com (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://example.com"
#code: 0
#file: "./vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php"
#line: 663
-previous: GuzzleHttp\Exception\ConnectException^ {#7644
-request: GuzzleHttp\Psr7\Request^ {#7636
-method: "GET"
-requestTarget: null
-uri: GuzzleHttp\Psr7\Uri^ {#7633
-scheme: "https"
-userInfo: ""
-host: "example.com"
-port: null
-path: ""
-query: ""
-fragment: ""
}
....
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community