title: cURL error 28: Operation timed out after 2000 milliseconds with 7276200 out of 23000995 bytes received
body: <h1>Description</h1>
  <p>I'm using Guzzle in my Laravel project. I had a memory crash when I make a request to an API that return a huge payload.</p>
  <p>I have this on the top of my <code>CURL.php</code> class.  I have get() that I use Guzzle.</p>
  <pre><code>use GuzzleHttp\Exception\GuzzleException;
  use GuzzleHttp\Client;
  use GuzzleHttp\FORCE_IP_RESOLVE;
  use GuzzleHttp\DECODE_CONTENT;
  use GuzzleHttp\CONNECT_TIMEOUT;
  use GuzzleHttp\READ_TIMEOUT;
  use GuzzleHttp\TIMEOUT;
  
  class CURL {
  
      public static function get($url) {
  
          $client = new Client();
          $options = [
              'http_errors' =&gt; true,
              'force_ip_resolve' =&gt; 'v4',
              'connect_timeout' =&gt; 2,
              'read_timeout' =&gt; 2,
              'timeout' =&gt; 2,
          ];
          $result = $client-&gt;request('GET',$url,$options);
          $result = (string) $result-&gt;getBody();
          $result = json_decode($result, true);
          return $result;
  
      }
  
      ...
  
  }
  </code></pre>
  <p>When I call it like this in my application, it request a large payload (30000)</p>
  <pre><code>$url = 'http://site/api/account/30000';
  $response =  CURL::get($url)['data'];
  </code></pre>
  <p>I kept getting this error</p>
  <blockquote>
  <p>cURL error 28: Operation timed out after 2000 milliseconds with 7276200 out of 23000995 bytes received (see <a href="http://curl.haxx.se/libcurl/c/libcurl-errors.html" rel="nofollow noreferrer">http://curl.haxx.se/libcurl/c/libcurl-errors.html</a>)</p>
  </blockquote>
  <p>How do I avoid this?</p>
  <p>Should I increase these settings?</p>
  <pre><code>'connect_timeout' =&gt; 2,
  'read_timeout' =&gt; 2,
  'timeout' =&gt; 2,
  </code></pre>