"curl --retry-max-time <seconds>"如何工作?

kev*_*kev 32 curl

我不知道怎么--retry-max-time计算.如果我下载文件file.txt:

curl --max-time 10 --retry 3 --retry-delay 5 --retry-max-time 32 'http://www.site.com/download/file.txt'
Run Code Online (Sandbox Code Playgroud)
  • [ 0- 2]它需要2s下载50%文件,而且没有速度了.
  • [ 2-10]它等待另一个8s,仍然没有速度,超时,将重试
  • [10-15]5s在重试#1之前等待
  • [15-25] 仍然没有速度,将重试
  • [25-30]5s在重试#2之前等待
  • [30-34]它需要4s下载33%文件,而且没有速度了.
  • [34-40]它等待另一个6s,仍然没有速度,超时

此时会curl停止重试(40s)吗?

什么时候retry timer开始和停止?


   --retry-max-time <seconds>
          The  retry  timer  is reset before the first transfer attempt. Retries will be done as usual (see --retry) as
          long as the timer hasn't reached this given limit. Notice that if the timer hasn't  reached  the  limit,  the
          request  will be made and while performing, it may take longer than this given time period. To limit a single
          request´s maximum time, use -m, --max-time.  Set this option to  zero  to  not  timeout  retries.  (Added  in
          7.12.3)
Run Code Online (Sandbox Code Playgroud)

kev*_*kev 48

curl --connect-timeout 5 \
     --max-time 10 \
     --retry 5 \
     --retry-delay 0 \
     --retry-max-time 60 \
     'http://www.site.com/download/file.txt'
Run Code Online (Sandbox Code Playgroud)
|<---0---->| {<---1---->|  |<---2---->|    |<---3---->|   |<---4---->|   }            |<---5---->|
|....==    | {...==     |  |....==    |    |.....|        |..=== =   |   }
             {                                                           }
Run Code Online (Sandbox Code Playgroud)

符号

=====  downloading...       (file size is 5)
.....  --connect-timeout 5
|<->|  --max-time 10
<-5->  --retry 5
>| |<  --retry-delay 0      ([default] exp backoff algo)
{   }  --retry-max-time 60  (GAME OVER)
Run Code Online (Sandbox Code Playgroud)

注意

  • 重试延迟1,2,4,8 ......
  • 重试#3连接超时
  • 重试#5永远不会发生
  • END(71秒)下载失败

  • 非常棒的照片.为了让读者更快,通过示例的一些文本将是有帮助的.无论如何,有点耐心在这里证明是有用的. (2认同)

Dan*_*erg 17

让我试着澄清一下.

当curl决定进行重试(因为--retry使用并且条件是保证重试)并且--retry-max-time设置了a 时,curl检查自操作开始以来经过的总时间是否已超过--retry-max-time或不超过.如果没有,它将允许另一次重试.

所以在上面的命令行中:如果在考虑重试时总时间小于32秒,它将进行另一次重试.如果总时间超过32秒,则不再进行重试.