Support the ongoing development of Laravel.io →
posted 4 years ago

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.

  • Tested environment: macOS 11.4
  • Laravel Version: ^8.37.0
  • PHP Version: 8.0.7

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!

Steps To Reproduce:

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: ""
      }
....      
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

bukloe bukloe Joined 30 Mar 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.