Skip to content

Commit 90a4cc8

Browse files
authored
Make timeouts default to 60 seconds (#992)
The client-side timeout implementation has gotten much more reliable and robust over the last little while. The reason we didn't include a timeout by default is that it wasn't in the past, but now I believe things are robust enough to set it and catch unresponsive servers for clients without waiting on the response indefinitely.
1 parent ea025e1 commit 90a4cc8

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/ConnectionPool.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ function getconnection(::Type{TCPSocket},
414414
# alive in the face of heavy workloads where Julia's task scheduler might take a while to
415415
# keep up with midflight requests
416416
keepalive::Bool=true,
417-
connect_timeout::Int=0,
418-
readtimeout::Int=0,
417+
connect_timeout::Int=60,
418+
readtimeout::Int=60,
419419
kw...)::TCPSocket
420420

421421
p::UInt = isempty(port) ? UInt(80) : parse(UInt, port)
@@ -539,7 +539,7 @@ end
539539
function sslupgrade(::Type{IOType}, c::Connection,
540540
host::AbstractString;
541541
require_ssl_verification::Bool=NetworkOptions.verify_host(host, "SSL"),
542-
readtimeout::Int=0,
542+
readtimeout::Int=60,
543543
kw...)::Connection{IOType} where {IOType}
544544
# initiate the upgrade to SSL
545545
# if the upgrade fails, an error will be thrown and the original c will be closed

src/HTTP.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ Supported optional keyword arguments:
117117
will be written to this stream instead of returned as a `Vector{UInt8}`.
118118
- `verbose = 0`, set to `1` or `2` for increasingly verbose logging of the
119119
request and response process
120-
- `connect_timeout = 0`, close the connection after this many seconds if it
120+
- `connect_timeout = 60`, close the connection after this many seconds if it
121121
is still attempting to connect. Use `connect_timeout = 0` to disable.
122122
- `connection_limit = 8`, number of concurrent connections allowed to each host:port.
123-
- `readtimeout = 0`, close the connection if no data is received for this many
123+
- `readtimeout = 60`, close the connection if no data is received for this many
124124
seconds. Use `readtimeout = 0` to disable.
125125
- `status_exception = true`, throw `HTTP.StatusError` for response status >= 300.
126126
- Basic authentication is detected automatically from the provided url's `userinfo` (in the form `scheme://user:password@host`)

src/clientlayers/ConnectionRequest.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Close the connection if the request throws an exception.
5555
Otherwise leave it open so that it can be reused.
5656
"""
5757
function connectionlayer(handler)
58-
return function(req; proxy=getproxy(req.url.scheme, req.url.host), socket_type::Type=TCPSocket, socket_type_tls::Type=SOCKET_TYPE_TLS[], readtimeout::Int=0, kw...)
58+
return function(req; proxy=getproxy(req.url.scheme, req.url.host), socket_type::Type=TCPSocket, socket_type_tls::Type=SOCKET_TYPE_TLS[], readtimeout::Int=60, kw...)
5959
local io, stream
6060
if proxy !== nothing
6161
target_url = req.url

src/clientlayers/TimeoutRequest.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export timeoutlayer
1111
Close the `HTTP.Stream` if no data has been received for `readtimeout` seconds.
1212
"""
1313
function timeoutlayer(handler)
14-
return function(stream::Stream; readtimeout::Int=0, kw...)
14+
return function(stream::Stream; readtimeout::Int=60, kw...)
1515
if readtimeout <= 0
1616
# skip
1717
return handler(stream; kw...)

0 commit comments

Comments
 (0)