Skip to content

Commit 140b22b

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. (cherry picked from commit 84e948c)
1 parent 7a74621 commit 140b22b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Curl/Easy.jl

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ function set_defaults(easy::Easy)
5151
setopt(easy, CURLOPT_USERAGENT, USER_AGENT)
5252
setopt(easy, CURLOPT_SSL_OPTIONS, CURLSSLOPT_REVOKE_BEST_EFFORT)
5353

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

0 commit comments

Comments
 (0)