Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does "curl --retry-max-time <seconds>" work?

Tags:

curl

I don't know how --retry-max-time calculated. If I download a file file.txt:

curl --max-time 10 --retry 3 --retry-delay 5 --retry-max-time 32 'http://www.site.com/download/file.txt' 

  • [ 0- 2] It takes 2s to download 50% of the file, and no speed any more.
  • [ 2-10] It waits for another 8s, still no speed, timeout, will retry
  • [10-15] It waits for 5s before retry #1
  • [15-25] Still no speed, will retry
  • [25-30] It waits for 5s before retry #2
  • [30-34] It takes 4s to download 33% of the file, and no speed any more.
  • [34-40] It waits for another 6s, still no speed, timeout

Will curl stop retry at this point(40s)?

When was the retry timer started and stopped?


   --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) 
like image 468
kev Avatar asked May 13 '12 00:05

kev


People also ask

Does curl have a retry?

Using the --retry option you can tell curl to retry certain failed transfers. If a transient error is returned when curl tries to perform a transfer, it will retry this number of times before giving up. Setting the number to 0 makes curl do no retries (which is the default).

How do you retry in curl command?

When curl is about to retry a transfer, it will first wait one second and then for all forthcoming retries it will double the waiting time until it reaches 10 minutes which then will be the delay between the rest of the retries. By using --retry-delay you disable this exponential backoff algorithm.


1 Answers

curl --connect-timeout 5 \      --max-time 10 \      --retry 5 \      --retry-delay 0 \      --retry-max-time 60 \      'http://www.site.com/download/file.txt' 

|<---0---->| {<---1---->|  |<---2---->|    |<---3---->|   |<---4---->|   }            |<---5---->| |....==    | {...==     |  |....==    |    |.....|        |..=== =   |   }              {                                                           } 

NOTATION

=====  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) 

NOTE

  • retry delay 1, 2, 4, 8 ...
  • retry #3 connect timeout
  • retry #5 never happen
  • download failed at END (71 sec)
like image 171
kev Avatar answered Oct 10 '22 13:10

kev