How to configure Vert.x for HTTP/2 without TLS

1,973 views
Skip to first unread message

Tim Fox

unread,
Feb 17, 2020, 3:45:41 AM2/17/20
to vert.x
Hi folks,

I am trying to get a vert.x WebClient to talk to a Vert.x HTTP server using HTTP/2 but without using TLS (It works fine using TLS).

I start the server with SSL disabled, and I connect using a WebClient after setting ProtocolVersion to HttpVersion.HTTP_2, but it fails with the error:

"HTTP/2 client preface string missing or corrupt".

Is there some other property I need to set here?


Julien Viet

unread,
Feb 17, 2020, 5:31:09 AM2/17/20
to ve...@googlegroups.com
Hi,

à priori it should work out of the box.


if you provide a reproducer we can investigate

Julien

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/f77a5e12-8d9b-493b-b5f2-d185ae06fe91%40googlegroups.com.

Tim Fox

unread,
Feb 17, 2020, 8:52:55 AM2/17/20
to vert.x
Hey Julien,

The issue only seems to occur when I send the request body as a stream, if I send it as a buffer or string it works ok.

I'm probably doing something dumb with the stream, but can't figure it out.


The server basically just echoes back the request body to the response.

The client attempts to submit a POST using a stream to provide the body.

You should see an exception logged out when you run it.

Thanks!


On Monday, 17 February 2020 10:31:09 UTC, Julien Viet wrote:
Hi,

à priori it should work out of the box.


if you provide a reproducer we can investigate

Julien

On 17 Feb 2020, at 09:45, Tim Fox <timv...@gmail.com> wrote:

Hi folks,

I am trying to get a vert.x WebClient to talk to a Vert.x HTTP server using HTTP/2 but without using TLS (It works fine using TLS).

I start the server with SSL disabled, and I connect using a WebClient after setting ProtocolVersion to HttpVersion.HTTP_2, but it fails with the error:

"HTTP/2 client preface string missing or corrupt".

Is there some other property I need to set here?



--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.

Julien Viet

unread,
Feb 17, 2020, 12:37:43 PM2/17/20
to ve...@googlegroups.com
Hi Tim,

thanks for the reproducer, it seems due to the HTTP request being chunked.

When using HTTP over clear text (h2c) the default choice is to use an HTTP upgrade mechanism to establish an HTTP/2 channel. However the first HTTP request is always used as the first request, i.e if you do an HTTP post and send a body then the first request will be done using HTTP/1 and a real chunked encoded request (while the server will respond with an HTTP/2 response)

It seems that setting the request as chunked messes up with the HTTP/2 upgrade, this is a bug and will be fixed.

As work-around if you do control the HTTP2 server and it supports it I would recommend using H2C with prior knowledge which is still clear text but without HTTP upgrades (both client and server directly uses HTTP/2 encoding in clear text). Vertx HTTP server supports it out of the box and Vertx HTTP client supports it by using the calling setHttp2ClearTestUpgrade(false) on the options to enable it.

Julien

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/255a078c-d420-49e8-8f3e-813080b7a3fd%40googlegroups.com.

Tim Fox

unread,
Feb 17, 2020, 4:57:17 PM2/17/20
to vert.x
Thank you sir, all working now (with the workaround) :)

Julien Viet

unread,
Feb 17, 2020, 5:06:09 PM2/17/20
to ve...@googlegroups.com
great! I'm glad it work for you.

This is actually more than a work around as it is spec compliant.

In practice it is more efficient to use because the upgrade mechanism of the first request will block other concurrent requests your client might be doing (so if you send a large body, other requests will have to wait until the first request is fully sent).

With prior knowledge connection fully multiplexes all requests.

So if you can afford using it, then you should go for it.

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/a1fe312b-d982-488d-895c-07a3f0e8a8df%40googlegroups.com.

Julien Viet

unread,
Feb 18, 2020, 5:15:09 AM2/18/20
to ve...@googlegroups.com
Hi,


The patch should be released in 3.9 and next 4.0 milestone.

Julien
Reply all
Reply to author
Forward
0 new messages