Why is the CURL timeout of 1000 ms when I set the timeout to 3000 ms?

In one of my script I set the curl time CURLOPT_CONNECTTIMEOUT_MS to 3000 ms, but the curl time is much earlier than average, on average 1000 ms. Why is it so early?

+3
source share
2 answers

I believe that the timeout you see is the timeout of the CURL operation, not the connection timeout. These two are different.

CURLOPT_TIMEOUT(and CURLOPT_TIMEOUT_MSfor millisecond values) controls the timeout for CURL to work after it is connected. CUROPT_CONNECTTIMEOUT(i CUROPT_CONNECTTIMEOUT_MS) control the timeout for the initial connection (DNS lookup, connection establishment, etc.)

If I am right, then if you set CURLOPT_TIMEOUT above 1, you should find that your timeout no longer works at 1000 ms.

+6

CURL PHP. CURLOPT_CONNECTTIMEOUT_MS cURL 7.16.2. PHP 5.2.3. http://php.net/manual/en/function.curl-setopt.php

0

All Articles