Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP curl CURLOPT_CONNECTTIMEOUT has no effect on connection timeout
    primarykey
    data
    text
    <p>I have following settings:</p> <pre><code>$handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($handle, CURLOPT_TIMEOUT, 30); curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($handle, CURLOPT_POST, true); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); $response = curl_exec($handle); </code></pre> <p>But when request is sent to server, which is currently not responding at all, curl returns answer in 1 second. I don't understand why that is happening, because I have set CURLOPT_CONNECTTIMEOUT to 30, which should mean that curl tires to connect to server 30 seconds. I need curl to try connection for 30 seconds, isn't that what CURLOPT_CONNECTTIMEOUT is supposed to do, or is there some kind of misunderstanding?</p> <p>Here is what print_r(curl_getinfo($handle), true) returns:</p> <pre><code>( [url] =&gt; http://server.url [content_type] =&gt; [http_code] =&gt; 0 [header_size] =&gt; 0 [request_size] =&gt; 0 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 0 [total_time] =&gt; 1.045 [namelookup_time] =&gt; 0.016 [connect_time] =&gt; 0 [pretransfer_time] =&gt; 0 [size_upload] =&gt; 0 [size_download] =&gt; 0 [speed_download] =&gt; 0 [speed_upload] =&gt; 0 [download_content_length] =&gt; -1 [upload_content_length] =&gt; -1 [starttransfer_time] =&gt; 0 [redirect_time] =&gt; 0 [certinfo] =&gt; Array ( ) [redirect_url] =&gt; ) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload