为什么CURL在1000ms时超时,当我设置超时3000ms? [英] Why would CURL time out in 1000ms when I have set up timeout upto 3000ms?
问题描述
在我的一个脚本中,我已经设置curl超时,CURLOPT_CONNECTTIMEOUT_MS,到3000ms,但curl超时时间比平均超过1000ms。为什么会这么早呢?
我相信你看到的超时是一个CURL操作超时,而不是连接超时。这两个是不同的。
CURLOPT_TIMEOUT
(和 CURLOPT_TIMEOUT_MS
为毫秒值)控制工作CURL在它连接后的工作的超时。 CUROPT_CONNECTTIMEOUT
(和 CUROPT_CONNECTTIMEOUT_MS
)控制初始连接的超时(DNS查找,建立连接等) / p>
如果我是对的,那么如果你设置CURLOPT_TIMEOUT高于1,你应该会发现你的超时不会在1000ms再跳。
In one of my script I have set up curl time out, CURLOPT_CONNECTTIMEOUT_MS, to 3000ms, but curl time outs much before than that, at an average of 1000ms. Why would it time out so early?
I believe the timeout you are seeing is a CURL operation timeout, rather than a connection timeout. These two are different.
CURLOPT_TIMEOUT
(and CURLOPT_TIMEOUT_MS
for millisecond values) control the timeout for the work CURL does after it's connected. CUROPT_CONNECTTIMEOUT
(and CUROPT_CONNECTTIMEOUT_MS
) control the timeout for the initial connection (DNS lookup, establishing the connection, etc.)
If I'm right, then if you set CURLOPT_TIMEOUT higher than 1, you should find that your timeout doesn't trip at 1000ms any more.
这篇关于为什么CURL在1000ms时超时,当我设置超时3000ms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!