quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.58k stars 2.63k forks source link

Http Client should support Http/2 #13969

Closed pjgg closed 9 months ago

pjgg commented 3 years ago

Description Quarkus httpClient (quarkus-rest-client) should be able to works over http/2 as the server-side does. Otherwise, if we use quarkus-rest-client for example to exchange data between microservices, then the server(even if is able to talk on Http/2) will talk on the same protocol as the client libraries (Http1.1).

Implementation ideas

Well, I will try to support several clients over the same interface (StrategyPattern). So quarkus-rest-client must be just the common interface of several HttpClient as ...VertxHttpClient (that supports Http/2), OkHttp3, ApacheHttpClient...etc And then depends on your configuration, you should have some specific application.properties.

Example: Lets add the proposal common HttpClient interface quarkus-rest-client and an implementation interface smallrye-mutiny-vertx-web-client

Dependencies:

 <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-rest-client</artifactId>
 </dependency>

 <dependency>
         <groupId>io.smallrye.reactive</groupId>
         <artifactId>smallrye-mutiny-vertx-web-client</artifactId>
 </dependency>

application.properties

quarkus.client.http.http2=true
quarkus.client.http.ssl=true
quarkus.client.http.alpn=true
quarkus.client.http.truststore=META-INF/resources/client.keystore
quarkus.client.http.hostverified=false

Thank U!.

External references:

Jira Issue

gsmet commented 3 years ago

@asoldano is HTTP 2 supported by the RESTEasy REST client? And if not, is there any plan to support it?

asoldano commented 3 years ago

@ronsigal ^

ronsigal commented 3 years ago

It looks like we would have to upgrade to HttpClient 5.0. I don't know yet what the implications would be, but I think it's a great idea.

ronsigal commented 3 years ago

JIRAs with tentative Fix Versions:

geoand commented 2 years ago

@michalszynkiewicz does the Reactive REST Client support HTTP 2 ?

michalszynkiewicz commented 2 years ago

Vert.x HTTP Client supports http/2. HTTPClientOptions don't have a setting for enabling http/2 so I guess rest client reactive should just use it if available but I never tested it.

michalszynkiewicz commented 2 years ago

I was wrong, there is an option to specify HTTP/2, you do it with HTTPClientOptions#setProtocolVersion(HttpVersion.HTTP_2).

geoand commented 2 years ago

Interesting, I wonder if we should expose it

michalszynkiewicz commented 2 years ago

I think it would be good to do so

kostacasa commented 2 years ago

Is there a way to manually enable this on Quarkus 2.x services before it's exposed by Quarkus directly? Adding HTTP/2 support would be a great improvement to improve efficiency of high throughput API integrations. Calling other HTTP services is presumably something that most Quarkus services do.

Sgitario commented 1 year ago

Partial fix to give support in REST Client Reactive: https://github.com/quarkusio/quarkus/pull/31192

cescoffier commented 9 months ago

I would rather not have complex things like multiple client implementations. We already have 2 (classic and reactive), and it's hard to keep an eye on everything.

The reactive rest client supports HTTP/2, so closing this issue is recommended.