h2c with upgrade doesn't work

233 views
Skip to first unread message

Alexis Hassler

unread,
Mar 30, 2018, 10:54:53 AM3/30/18
to vert.x
Hi,

I'm trying to use Vert.x (3.5.1) as a HTTP/2 h2c server.

I'm starting a simple HTTP server like this :

vertx.createHttpServer()
     .requestHandler(request -> request.response().end("OK"))
     .listen(8000);

I'm testing with the nghttp command line tool.

This first command works fine (h2c direct) :

~$ nghttp http://localhost:8000

But with the upgrade option, the client never receives the response.

~$ nghttp -u http://localhost:8000

Here is the output with the verbose option.

~$ nghttp -v -u http://localhost:8000

[  0.001] Connected
[  0.001] HTTP Upgrade request
GET / HTTP/1.1
host: localhost:8000
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.7.1


[  0.004] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols
connection: upgrade
upgrade: h2c
content-length: 0


[  0.004] HTTP Upgrade success
[  0.004] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.004] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
          (dep_stream_id=0, weight=201, exclusive=0)
[  0.004] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
          (dep_stream_id=0, weight=101, exclusive=0)
[  0.004] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
          (dep_stream_id=0, weight=1, exclusive=0)
[  0.004] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
          (dep_stream_id=7, weight=1, exclusive=0)
[  0.004] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
          (dep_stream_id=3, weight=1, exclusive=0)
[  0.004] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
          (dep_stream_id=11, weight=16, exclusive=0)
[  0.005] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_MAX_HEADER_LIST_SIZE(0x06):8192]
[  0.005] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[  0.006] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)

I have something similar with curl.

Alexis

Julien Viet

unread,
Mar 30, 2018, 11:05:28 AM3/30/18
to ve...@googlegroups.com
in the log, I don't see the client sending an HEADER frame.

have you tried with other servers ?



--
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.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9371b91a-7722-4dd9-bb39-2b825cbe0ffa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexis Hassler

unread,
Mar 30, 2018, 12:46:36 PM3/30/18
to vert.x
With Tomcat 9, nghttp fails at the upgrade step with an error message.
And curl works fine.

Here is the verbose output of curl with Tomcat :

*   Trying 172.44.0.100...
* TCP_NODELAY set
* Connected to demo.server (172.44.0.100) port 8002 (#0)
> GET /hello HTTP/1.1
> Host: demo.server:8002
> User-Agent: curl/7.56.0
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA
>
< HTTP/1.1 101
< Connection: Upgrade
< Upgrade: h2c
< Date: Fri, 30 Mar 2018 15:20:28 GMT
* Received 101
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200
< accept-ranges: bytes
< etag: W/"25-1522219727000"
< last-modified: Wed, 28 Mar 2018 06:48:47 GMT
< date: Fri, 30 Mar 2018 15:20:28 GMT
<

      Hello World 👋

* Connection #0 to host demo.server left intact


And here is its output with vert.x :

* TCP_NODELAY set
* Connected to demo.server (172.44.0.100) port 8002 (#0)
> GET /hello HTTP/1.1
> Host: demo.server:8002
> User-Agent: curl/7.56.0
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA

>
< HTTP/1.1 101 Switching Protocols
< connection: upgrade
< upgrade: h2c
< content-length: 0
* Received 101
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!

Then curl is hanging until I kill the Vert.x process (ou close the connection).

Julien Viet

unread,
Mar 31, 2018, 4:51:03 AM3/31/18
to ve...@googlegroups.com
you are right it cannot work, the fix is actually non trivial...

I'll file an issue for this.

Julien

Julien Viet

unread,
Apr 5, 2018, 10:53:51 AM4/5/18
to ve...@googlegroups.com
Hi Alexis,

I've done this PR which supports now correctly h2c upgrade protocol.


Julien
Reply all
Reply to author
Forward
0 new messages