Reactor-netty: How to configure read timeout?

Created on 1 Jan 2017  路  10Comments  路  Source: reactor/reactor-netty

fostackoverflow typdocumentation

Most helpful comment

@danielra With Reactor Netty 0.7.x we recommend to use Netty's Read/WriteTimeoutHandler thus the connection will be closed when the timeout is reached. With Reactor Netty 0.8.x you can use Flux/Mono#timeout, the connection will be closed when the timeout is reached.

All 10 comments

We have a connect timeout (TCP connection timeout) in HttpClientOptions you pass to HttpClient/HttpServer.create(options -> options.xxxx). Another default one is used for connection pooling (10s), so failing to acquire will error too.
But we don't yet listen for idle read/connections, which you can do with Flux#receive().timeout(xxx, xxx)

Am I wrong or isn't the ChannelOption.SO_TIMEOUT the same as a read timeout?

@joshiste Netty uses ChannelOption.SO_TIMEOUT only for OIO transport so it's not applicable. (SO: https://stackoverflow.com/a/22897119)

@smaldini When using the mentioned Flux#receive().timeout(xxx, xxx) approach, will the underlying (pooled) connection be closed / released upon timeout? Or is there a risk of exhausting the connection pool because the underlying connection(s) keep waiting to receive slow responses even though the application logic has moved on and won't actually care about the response?

@danielra With Reactor Netty 0.7.x we recommend to use Netty's Read/WriteTimeoutHandler thus the connection will be closed when the timeout is reached. With Reactor Netty 0.8.x you can use Flux/Mono#timeout, the connection will be closed when the timeout is reached.

Due to the open state I wonder if the feature indeed was landed in version 0.8 or not.

Due to the modified milestone I guess this is not the case?

We are quite eager to be able to use this feature on a per route basis within spring-cloud-gateway instead of hystrix or ribbon due to their deprecation with the last spring-cloud release.

@frko Can't you use the Spring Gateway functionality?
spring.cloud.gateway.httpclient.response-timeout

I can but this will leak resources if the underlying connection isn't properly closed.

Was this page helpful?
0 / 5 - 0 ratings