With the new HttpClient/TcpClient configuration APIs, I've tried customizing the timeout options for the HTTP client.
While I can change the connection timeout like this:
TcpClient tcpClient = TcpClient.create();
tcpClient.configure()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000);
HttpClient httpClient = HttpClient.from(tcpClient);
I cannot find a way to configure the read and write timeouts, as it was previously explained in this StackOverflow answer. Is there still a way (or an easier way) to configure that part of the HttpClient?
@bclozel You can configure the timeouts like the sample below:
TcpClient tcpClient =
TcpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000)
.doOnConnected(connection ->
connection.addHandlerLast(new ReadTimeoutHandler(10))
.addHandlerLast(new WriteTimeoutHandler(10)));
HttpClient httpClient = HttpClient.from(tcpClient);
Thanks a lot @violetagg !
Most helpful comment
@bclozel You can configure the timeouts like the sample below: