reactor-netty

How to set a timeout in Spring 5 WebFlux WebClient

倖福魔咒の 提交于 2019-12-17 10:48:12
问题 I'm trying to set timeout on my WebClient, here is the current code : SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); ClientHttpConnector httpConnector = new ReactorClientHttpConnector(opt -> { opt.sslContext(sslContext); HttpClientOptions option = HttpClientOptions.builder().build(); opt.from(option); }); return WebClient.builder().clientConnector(httpConnector).defaultHeader("Authorization", xxxx) .baseUrl(this.opusConfig

Netty Server isn't used in Spring Boot 2 with Reactive starter

二次信任 提交于 2019-12-13 03:05:45
问题 I'm developing a reactive project using Spring Boot 2 and reactive starters. My problem is that when I start the app, the Tomcat server it's started instead of Netty. Here is my dependencies task from build.gradle file: dependencies { compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}") compile("org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}") compile("org.springframework.boot:spring-boot-starter-hateoas:${springBootVersion}")

How to customize Netty with Spring Boot 2.1 Webflux?

那年仲夏 提交于 2019-12-08 06:17:03
问题 I would like to customize Netty in my Spring Boot Webflux project. In my POM I added Spring Boot Webflux and Spring Boot Actuator dependencies. Next I overwrote the customize() method of WebServerFactoryCustomizer as described in the Spring documentation. @Component public class NettyConfiguration implements WebServerFactoryCustomizer<NettyReactiveWebServerFactory> { @Override public void customize(NettyReactiveWebServerFactory factory) { factory.addServerCustomizers(new NettyCustomizer()); }

Reading a HttpContent that has a PooledUnsafeDirectByteBuf

試著忘記壹切 提交于 2019-12-08 05:18:58
问题 I have a Reactor-Netty HttpServer, to which I send data that is more than 1024 bytes from an HttpClient. In the client I get the different parts of the request in a Flux with the idea of concatenating the data into a String that I can ultimately parse. I was of the opinion that this could have been done by the HttpObjectAggregator, but alas no. When the client receives the content it comes in as DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 1024, widx: 1024, cap: 1024/1024, unwrapped:

Springboot Webclient throws “An existing connection was forcibly closed by the remote host.”

巧了我就是萌 提交于 2019-12-07 11:14:37
问题 Springboot Webclient throws "An existing connection was forcibly closed by the remote host" error when trying to call rest api in remote server. When the server loads, the first server request loads fine. When I send the second request after some time (Say 5 mins), I am getting the error. Webclient creation code: WebClient webClient() { TcpClient tcpClient = TcpClient.create() .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000) .option(ChannelOption.SO_KEEPALIVE, false) .doOnConnected {

Reading a HttpContent that has a PooledUnsafeDirectByteBuf

泄露秘密 提交于 2019-12-07 01:59:34
I have a Reactor-Netty HttpServer, to which I send data that is more than 1024 bytes from an HttpClient. In the client I get the different parts of the request in a Flux with the idea of concatenating the data into a String that I can ultimately parse. I was of the opinion that this could have been done by the HttpObjectAggregator, but alas no. When the client receives the content it comes in as DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 1024, widx: 1024, cap: 1024/1024, unwrapped: PooledUnsafeDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success) and

Readable debug logging for http requests with spring webclient

对着背影说爱祢 提交于 2019-12-06 01:31:02
问题 I'm using Spring reactive WebClient for sending requests to a http server. Inorder to view the underlying request & response that's being sent, I enabled debug logging for reactor.ipc.netty package. The headers for the outgoing requests can be viewed normally. Tho I'm sending & receiving plain text over http, the log contains the request & responses in the below format (is it hex?) I'm not sure how to view the logged data in a easy to understand way. Better yet log the request & response in a

How to limit request payload size using Spring Webflux?

99封情书 提交于 2019-12-04 18:34:37
Using Spring Webflux, I need to limit the payload size of incoming HTTP requests (e.g. to say 5MB). Is this something configurable out-of-the-box? If not, which APIs can we use to implement this behavior (e.g. return a 413 if the payload is too big). I guess you want to do this to prevent Denial Of Service attacks by malicious or misbehaving clients. The usual recommendation is to not directly connect HTTP application servers to the Internet, but instead via an HTTP reverse proxy server (such as a suitably configured Apache HTTPD or nginx). These proxy servers provide means for blocking large

Readable debug logging for http requests with spring webclient

人盡茶涼 提交于 2019-12-04 07:36:09
I'm using Spring reactive WebClient for sending requests to a http server. Inorder to view the underlying request & response that's being sent, I enabled debug logging for reactor.ipc.netty package. The headers for the outgoing requests can be viewed normally. Tho I'm sending & receiving plain text over http, the log contains the request & responses in the below format (is it hex?) I'm not sure how to view the logged data in a easy to understand way. Better yet log the request & response in a understandable way Here is a snippet of the logged data +---------------------------------------------

Configure HostnameVerifier with reactor netty for spring-webflux WebClient

懵懂的女人 提交于 2019-12-04 00:28:53
I'm trying to configure spring-webflux WebClient (with reactor netty under the hood) with ssl and client hostname verification. I'm provided with javax.net.ssl.SSLContext, HostnameVerifier and a list of trusted hostnames (as string list). So far I've configured WebClient with my SSLContext, but I can't find a way to configure hostname verification. To state my problem: I have a set of trusted services hostnames (String list) and a HostnameVerifier. I want to configure my WebClient with it. Is there a possibility to do it with the javax.net.ssl.HostnameVerifier? Is there an alternative approach