I am using reactor netty httpClient to make my req...
# help
h
I am using reactor netty httpClient to make my requests. Via reactor netty's httpClient you can specify a protocol to use for the request or specify more than one: You can then specify the HTTP2 protocol of type H2, H2C or specify to use HTTP1.1. Reactor netty also gives the possibility to configure all 3 protocols together:
HttpClient client =
HttpClient.create()
.protocol(HTTP1.1, H2C, H2 );
We are having several problems in our tests when configuring the HTTP1.1 protocol together with another HTTP2 protocol. Basically when HTTP1.1 is configured together with H2C or H2, reactor netty at the first request sends a request of type Connection: upgrade to understand what type of protocol the server supports in order to use the right protocol for the request. However, we noticed that wiremock does not handle Connection: Upgrade requests.
wireMockRule.stubFor(
post(urlEqualTo("/index.html")).
withRequestBody(equalTo("Wikipedia in\r\n"
+ "\r\n"
+ "chunks."))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/html")
.withBody("it <b>works</b> !!"))
);
By placing a subFor of this type, we see that when the Connection: upgrade request arrives, it sees that the body is empty, so it breaks and closes the connection without actually managing the connection upgrade. We tried to introduce a subFor that manages the case in which a connection: upgrade arrives but the problem is that after having managed, wiremock closes the connection and therefore reactor netty is unable to continue the request. In particular we did something like:
wireMockRule.stubFor(
post(urlEqualTo("/index.html"))
.withHeader(String.valueOf(HttpHeaderNames.CONNECTION), containing("upgrade") )
.willReturn(aResponse()
.withStatus(200)
.withHeader(String.valueOf(HttpHeaderNames.CONNECTION), "upgrade")
.withHeader(String.valueOf(HttpHeaderNames.UPGRADE), "HTTP/2.0")
));
wireMockRule.stubFor(
post(urlEqualTo("/index.html")).
withRequestBody(equalTo("Wikipedia in\r\n"
+ "\r\n"
+ "chunks."))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/html")
.withBody("it <b>works</b> !!"))
);
The problem, however, is that by matching the first subFor, it still immediately closes the connection. So reactor netty is not able to go and send data. If configured together H2C and H2 the problem does not arise as Connection:upgrade over http2 is not supported. If configured HTTP1.1 alone the problem does not arise. Do you have a solution to handle this issue?
t
Hi @Hamado Dene, please could you open an GitHub issue and share a test case for this? The only thing I can see that might help in your example is that your upgrade stub should probably return a 101 response status rather than 200, but nonetheless I’m surprised WireMock is closing the connection. It shouldn’t by default if the client is configured to reuse them.
m
Hi Tom, Has a ticket been opened and a solution found? Sinceraly, Maxime
t
No and no
304 Views