Skip to content

Commit 84e948c

Browse files
add connect timeout; reinstate speed limit (#126)
- This adds a connection timeout of 30 seconds, closing #125 - It re-instates the lower speed limit that was briefly added in #85 and was accidentally reverted in the following pull request (#86) In combination, this should prevent downloads from hanging, whether because the server is unavailable and so the connection is never established, or because the server never sends any data after the connection is established. This does not put an absolute timeout on downloads since a very large download can take arbitrarily long while still making progress.
1 parent 99165c6 commit 84e948c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Curl/Easy.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ function set_defaults(easy::Easy)
5353
setopt(easy, CURLOPT_COOKIEFILE, "")
5454
setopt(easy, CURLOPT_SSL_OPTIONS, CURLSSLOPT_REVOKE_BEST_EFFORT)
5555

56+
# prevent downloads that hang forever:
57+
# - timeout no response on connect (more than 30s)
58+
# - if server transmits nothing for 20s, bail out
59+
setopt(easy, CURLOPT_CONNECTTIMEOUT, 30)
60+
setopt(easy, CURLOPT_LOW_SPEED_TIME, 20)
61+
setopt(easy, CURLOPT_LOW_SPEED_LIMIT, 1)
62+
5663
# ssh-related options
5764
setopt(easy, CURLOPT_SSH_PRIVATE_KEYFILE, ssh_key_path())
5865
setopt(easy, CURLOPT_SSH_PUBLIC_KEYFILE, ssh_pub_key_path())

0 commit comments

Comments
 (0)