curl-library
CURLOPT_TIMEOUT_MS < 1000 - requests not reaching server
Date: Wed, 20 Feb 2013 11:11:33 -0800 (PST)
I am using the curl extension of php , to talk to a server ( local server, for test purposes).
Unless I set, both CURLOPT_CONNECTTIMEOUT_MS and CURLOPT_TIMEOUT_MS, to at least 1000 , the request does not even reach the server, from the client . What could be going wrong here, with the code fragment / libraries ( curl / php ) though ?
( clienttest.php ): // original code: http://stackoverflow.com/questions/6801795/php-curl-timeout-ignored
<?php
$version = curl_version();
print_r($version);
$defaults = array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_NOBODY => TRUE,
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
CURLOPT_CONNECTTIMEOUT_MS => 1000,
CURLOPT_TIMEOUT_MS => 1000,
CURLOPT_MAXREDIRS => 5,
CURLOPT_USERAGENT => 'RandomAgent',
);
$url='http://localhost:1234';
$ch = curl_init($url);
curl_setopt_array($ch, $defaults);
$doc = curl_exec($ch);
?>
System Information:
Curl version: 7.27.0
Array
(
[version_number] => 465664
[age] => 3
[features] => 50813
[ssl_version_number] => 0
[version] => 7.27.0
[host] => x86_64-pc-linux-gnu
[ssl_version] => OpenSSL/1.0.1c
[libz_version] => 1.2.7
[protocols] => Array
(
[0] => dict
[1] => file
[2] => ftp
[3] => ftps
[4] => gopher
[5] => http
[6] => https
[7] => imap
[8] => imaps
[9] => ldap
[10] => ldaps
[11] => pop3
[12] => pop3s
[13] => rtmp
[14] => rtsp
[15] => smtp
[16] => smtps
[17] => telnet
[18] => tftp
)
)
$ php --version
PHP 5.4.6-1ubuntu1.1 (cli) (built: Nov 15 2012 01:18:34)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with XCache v2.0.0, Copyright (c) 2005-2012, by mOo
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-02-20