curl / Mailing Lists / curl-library / Single Mail



From: Daniel Stenberg via curl-library <>
Date: Wed, 10 Apr 2019 10:03:17 +0200 (CEST)

On Wed, 10 Apr 2019, Weixi Li via curl-library wrote:

> The default CURLOPT_CONNECTTIMEOUT value is 300 seconds. We are using
> libcurl in a FTP client behind a corporate proxy, and would like to choose a
> smaller connection timeout.
> Can anyone comment on if it would be safe to reduce the timeout to 30
> seconds or even lower? What was the rationale for the default value to be
> 300 seconds (a seemingly rather large value)?

The default 300 seconds was just arbitratrily picked at some point in time to
be very conservative but still at least give up at some point.

It is certinly safe to reduce the timeout to whatever value you think is fine.
You know your conditions and how long you're willing to wait for curl to try.
Having it set too low will only risk you canceling a connecton that could have
connected fine if you gave it more time.

Most systems will resend lost TCP SYN packets a few times with an exponential
backoff and in 30 seconds not all have finished retrying. But the connect
phase in curl also includes name resolving and TLS handshake etc so a slow
network with packet loss could at least in theory take a long time to connect.
In reality I doubt you see very many connects taking more than just a few
seconds .

Received on 2019-04-10