Discussion:
Client5, HTTP2 , https and proxy usage
Rémy Amouroux
2018-03-28 15:11:04 UTC
Permalink
Hi

Thanks Oleg for the answer on the possible logging options for client5.

I tried different setup to find a solution to my present problem, but without seeing light.

I’m trying to setup a connection to a http2 server, using https and a proxy (which can do only HTTP1).

Thus, the CONNECT operation to setup the SSL Tunnel should use http1 , then the traffic going through the tunnel first negociate the protocol, and then use http2 if available.
It’s what I understood from the output of curl 7.59.0 compiled with http2 support.
(I can provide the traces of my tests if necessary)

I’m using Java 9 as recommended in a previous exchange, in order to have ALPN.

First question : is it possible right now with httpclient5 ?

The tests I have done while forcing usage of http2 : using .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2), leads to
AsyncRetryExec:90 - I/O exception (org.apache.hc.core5.http2.H2ConnectionException) caught when processing request
to {tls}->http://94.23.118.210:80->https://korben.info:443: Frame size exceeds maximum

It seems quite logical : the client is trying to speak http2 to the proxy which is answering with http1.

But the same code using .setVersionPolicy(HttpVersionPolicy.NEGOTIATE), leads to :
Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <€ÿÿÿÿ>

Is there something I’m doing wrong ?

The code for the last test is attached to this mail.

I can provide the traces for the different tests if necessary.

regards

remyA
Oleg Kalnichevski
2018-03-28 17:54:05 UTC
Permalink
Post by Rémy Amouroux
Hi
Thanks Oleg for the answer on the possible logging options for
client5.
I tried different setup to find a solution to my present problem, but without seeing light.
I’m trying to setup a connection to a http2 server, using https and a
proxy (which can do only HTTP1).
Thus, the CONNECT operation to setup the SSL Tunnel should use http1
, then the traffic going through the tunnel first negociate the
protocol, and then use http2 if available.
It’s what I understood from the output of curl 7.59.0 compiled with
http2 support.
(I can provide the traces of my tests if necessary)
I’m using Java 9 as recommended in a previous exchange, in order to
have ALPN. 
First question : is it possible right now with httpclient5 ? 
Right now, it is not. It can be done but it will likely require some
work in both HttpCore and HttpClient.
Post by Rémy Amouroux
using .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2), leads to
AsyncRetryExec:90 - I/O exception
(org.apache.hc.core5.http2.H2ConnectionException) caught when
processing request 
to {tls}->http://94.23.118.210:80->https://korben.info:443: Frame size exceeds maximum
It seems quite logical : the client is trying to speak http2 to the
proxy which is answering with http1.
But the same code using
org.apache.hc.core5.http.ParseException: Invalid protocol version;
error at offset 0: <€ÿÿÿÿ>
Is there something I’m doing wrong ?
HttpClient 5 can either speak HTTP/1.1 or HTTP/2 on the same connection
but not both. It can negotiate a tunnel through an HTTP/1.1 proxy but
it cannot switch to HTTP/2 once the tunnel has been established.

Oleg
Post by Rémy Amouroux
The code for the last test is attached to this mail.
I can provide the traces for the different tests if necessary.
regards
remyA
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Loading...