I experience this error (see section) sometimes in my scraping script.
X is an integer number of bytes> 0, the actual number of bytes sent by the web server in response. I debugged this problem using Charles proxy and this is what I see

As you can see, the response does not have a Content-Length header: and the proxy server is still waiting for data (and therefore cURL waited 2 minutes and gave up)
The cURL error code is 28.
Below is some debugging information from the verl verb output with curl_getinfo () var_export 'of this request:
* About to connect() to proxy 127.0.0.1 port 8888 (#584) * Trying 127.0.0.1... * Adding handle: conn: 0x2f14d58 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 584 (0x2f14d58) send_pipe: 1, recv_pipe: 0 * Connected to 127.0.0.1 (127.0.0.1) port 8888 (#584) > GET http://bakersfield.craigslist.org/sof/3834062623.html HTTP/1.0 User-Agent: Firefox (WindowsXP) Mozilla/5.1 (Windows; U; Windows NT 5.1; en-GB ; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6 Host: bakersfield.craigslist.org Accept: */* Referer: http://bakersfield.craigslist.org/sof/3834062623.html Proxy-Connection: Keep-Alive < HTTP/1.1 200 OK < Cache-Control: max-age=300, public < Last-Modified: Thu, 11 Jul 2013 21:50:17 GMT < Date: Thu, 11 Jul 2013 21:50:17 GMT < Vary: Accept-Encoding < Content-Type: text/html; charset=iso-8859-1 < X-MCP-Cache-Control: max-age=2592000, public < X-Frame-Options: SAMEORIGIN * Server Apache is not blacklisted < Server: Apache < Expires: Thu, 11 Jul 2013 21:55:17 GMT * HTTP/1.1 proxy connection set close! < Proxy-Connection: Close < * Operation timed out after 120308 milliseconds with 4636 out of -1 bytes receiv ed * Closing connection 584 Curl error: 28 Operation timed out after 120308 milliseconds with 4636 out of -1 bytes received http://bakersfield.craigslist.org/sof/3834062623.htmlarray ( 'url' => 'http://bakersfield.craigslist.org/sof/3834062623.html', 'content_type' => 'text/html; charset=iso-8859-1', 'http_code' => 200, 'header_size' => 362, 'request_size' => 337, 'filetime' => -1, 'ssl_verify_result' => 0, 'redirect_count' => 0, 'total_time' => 120.308, 'namelookup_time' => 0, 'connect_time' => 0, 'pretransfer_time' => 0, 'size_upload' => 0, 'size_download' => 4636, 'speed_download' => 38, 'speed_upload' => 0, 'download_content_length' => -1, 'upload_content_length' => 0, 'starttransfer_time' => 2.293, 'redirect_time' => 0, 'certinfo' => array ( ), 'primary_ip' => '127.0.0.1', 'primary_port' => 8888, 'local_ip' => '127.0.0.1', 'local_port' => 63024, 'redirect_url' => '', )
Can I do something like adding a curl parameter to avoid these timeouts. And this is not a connection timeout, nor a data wait timeout - both of these settings do not work, since the curl really successfully connects and receives some data, so the error timeout is always ~ = 120,000 ms.