WebClient HTTP Request Timeout
See original GitHub issueI’d like for WebClient
and/or ClientRequest
to have first-class support for an HTTP request timeout. (i.e. the time it takes to receive a response after sending a request). Something similar to the java http client’s request timeout.
The currently documented use of netty’s ReadTimeoutHandler
/ WriteTimeoutHandler
is insufficient to use as an HTTP request timeout. Specifically they apply at the TCP level, which leads to problems like this:
- They apply during the SSL handshake, which might take longer than a typical HTTP response, due to the cryptography involved. Therefore, they would need to be set higher than desired for HTTP responses.
- They apply even when an HTTP request is not being processed. For example, they could cause a connection sitting in the connection pool to be closed, even though it might be able to be used a split-second later by another request.
The .timeout
operator on the reactive stream is insufficient to use as an HTTP request timeout as well. Specifically, it operates on the reactive stream, which includes things like obtaining a connection from the connection pool and potentially creating a new connection, in addition to the time it takes the client to receive a response. This leads to having to use a .timeout
value this is greater than the connection timeout plus the time to obtain the connection from the connection pool. So, the .timeout
operator cannot be used as an HTTP request timeout. I’m willing to “pay the price” of establishing connections occasionally (leading to waiting longer occasionally for the stream to emit), but I’d still like to set a lower HTTP request timeout, to ensure the stream emits values fast when a new connection is not established.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:14 (10 by maintainers)
Top GitHub Comments
I’ve exposed this on
WebClient
so you could do:Yes that’s the idea.