Comments (5)
@ragini16071998 Please provide some reproducible example.
from reactor-netty.
Hi @violetagg ,
Find below the reproducible example.
Here client server dependency looks like:
client1 -> server1(client2 -> server2)
Since we are doing some logging on the server1 side by using some HttpClient methods like doOnRequestError, doOnResponse, doOnResponseError etc(refer client2 config), but in case of client1 responseTimeout, we are not able to log anything because the client2 channel gets closed quietly and it doesn't get captured neither in doOnRequestError method nor in doOnResponseError method hence for such client1 API calls we are not able to log response status.
@Test
public void testMethod() {
HttpServer server2 =
HttpServer.create()
.port(8086)
.route(r ->
r.get("/goodMorning",
(req, res) ->
res.sendString(Mono.just("Good Morning!").delayElement(java.time.Duration.ofSeconds(1))
)));
DisposableServer ds2 = server2.bindNow();
HttpClient client2;
client2 = HttpClient.create()
.port(ds2.port())
.doOnRequestError((req, error) -> System.out.println("RequestError: " + error.getMessage()))
.doOnResponse((res, anything) -> System.out.println("ResponseMessage: " + res))
.doOnResponseError((res, error) -> System.out.println("ResponseError: " + error.getMessage()))
.doOnDisconnected((conn) -> System.out.println("Disconnected: " + conn));
HttpServer server1 =
HttpServer.create()
.port(8085)
.route(r -> r.get("/hello",
(req, res) ->
res.sendString(client2.get()
.uri("/goodMorning")
.responseContent()
.aggregate()
.asString())));
DisposableServer ds = server1.bindNow();
HttpClient client1;
client1 = HttpClient.create()
.port(ds.port())
.responseTimeout(java.time.Duration.ofMillis(5000));
String response =
client1.get()
.uri("/hello")
.responseContent()
.aggregate()
.asString()
.block();
System.out.println("Final Response: " + response);
}
from reactor-netty.
@ragini16071998 Thanks a lot for the test, this makes things clear.
You have this:
client1 -> server1(client2) -> server2
^ ^
connection1 connection2
Your configuration with doOn...
covers the connection2
, while what actually happens is that connection1
is closed due to a timeout.
When connection1
is closed, the only thing that the server1
will do is to cancel
the Publisher
provided by client2
. You need to start listening for that kind of cancellations. Here is the configuration that you need:
HttpServer server1 =
HttpServer.create()
.port(8085)
.route(r -> r.get("/hello",
(req, res) ->
res.sendString(client2.get()
.uri("/goodMorning")
.responseContent()
.aggregate()
.asString())
.then()
--> listen for cancel signal .doOnCancel(() -> System.out.println("Cancel signal received"))));
This explains why you are entering the code in your first comment -> because the inbound was canceled.
You can also add doOnCancel
on the level of client2
client2.get()
.uri("/goodMorning")
.responseContent()
.aggregate()
.asString()
.doOnCancel(...)
from reactor-netty.
Here you can find an interesting implementation similar to your test https://github.com/spring-cloud/spring-cloud-gateway/blob/fb3b782afc40db9c220667ff8cc52d4968075099/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/NettyWriteResponseFilter.java#L64-L104
https://github.com/spring-cloud/spring-cloud-gateway/blob/fb3b782afc40db9c220667ff8cc52d4968075099/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/NettyRoutingFilter.java#L147-L199
from reactor-netty.
@ragini16071998 I'm closing this as I think there is no issue with Reactor Netty. We can reopen it if needed.
from reactor-netty.
Related Issues (20)
- Unable to configure Websocket compression when both HttpProtocol.H2C and HttpProtocol.HTTP1.1 are configured HOT 2
- Is it possible to be able to add custom labels to the metrics already being emitted HOT 2
- Regression from SpringBoot 3.2.2 Factory method 'webClientHttpConnector' threw exception with message: Cannot reserve 49152 bytes of direct buffer memory (allocated: 10452747, limit: 10485760) HOT 8
- out of memory when prometheus is enabled and url with path varaible HOT 5
- Error decoding client data HOT 6
- Enabling DNS retryOnTimeout with TCP HOT 2
- Inconsistent reactor_netty_http_client_* and reactor_netty_tcp_client_* metrics when proxy in use HOT 6
- Connections warming up HOT 4
- default port based on PORT environment variable HOT 1
- Graceful shutdown of HttpClient HOT 6
- Reactor Netty IllegalReferenceCountException: refCnt: 0 HOT 11
- Support For Spnego Auth scheme support for netty HttpClient similar to Apache's HOT 3
- HTTP/1.1 is being logged and recorded by metrics even though HTTP/2 is enabled HOT 10
- proxy-authorization header is not propagated to proxy server HOT 9
- Support for Spengo auth scheme support for netty HttpClient similar to Apache HttpClient HOT 2
- Spring Cloud Gateway use reactor netty :Response header and response body packet capture were found to be separate HOT 1
- CompletableFuture is cancelled because Netty is closing the connection channel HOT 5
- WebSockets - MaxFramePayloadLength behaviour when using WebSocketServerSpec.compress(true) HOT 2
- Timeout leaves connection in the pool in configured state, blocking a pool slot HOT 17
- ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactor-netty.