最新消息:

curl 连接超时,执行超时

curl admin 3733浏览 0评论

连接超时

[root@aikaiyuan ~]# curl --connect-timeout 1 http://2.2.2.2
curl: (28) Connection timed out after 1001 milliseconds

连接超时

       --connect-timeout <seconds>
              Maximum time in seconds that you allow curl's connection to take.  This only limits the connection phase, so if curl connects within the
              given period it will continue - if not it will exit.  Since version 7.32.0, this option accepts decimal values.

              If this option is used several times, the last one will be used.

              See also -m, --max-time.

最大执行时间

[root@aikaiyuan ~]# curl --max-time 2 http://2.2.2.2
curl: (28) Operation timed out after 2005 milliseconds with 0 bytes received

curl 最大执行时间, 有时候连接成功了, 但服务端长时间未返回,可以使用 max-time

       -m, --max-time <seconds>
              Maximum time in seconds that you allow the whole operation to take.  This is useful for preventing your  batch  jobs  from  hanging  for
              hours  due to slow networks or links going down.  Since 7.32.0, this option accepts decimal values, but the actual timeout will decrease
              in accuracy as the specified timeout increases in decimal precision.

              If this option is used several times, the last one will be used.

              See also --connect-timeout.

转载请注明:爱开源 » curl 连接超时,执行超时

您必须 登录 才能发表评论!