1

I would like to run a wireshark on http/2 for port 80 to

1. be able to test out an http/2 client
2. follow a wireshark trace to understand the protocol better

Is there a website that supports http/2 on port 80? When I go to google, it is always changing me to https.

thanks, Dean

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
  • 1
    clear the web browser cache and go to `https://www.google.com/`. You can use additionally "Network" tab of Developer Tools of Google Chrome/Internet Explorer to see HTTP/2 traffic. You need enable decryption of SSL/TLS (see [here](https://jimshaver.net/2015/02/11/decrypting-tls-browser-traffic-with-wireshark-the-easy-way/) for example, search for `SSLKEYLOGFILE`) to examine HTTP/2 traffic. You will be able to filter by `http2` or by `tcp.port == 443`, but not by post 80. – Oleg May 19 '16 at 22:09
  • The spec https://tools.ietf.org/html/rfc7540 says http/2 is supported on port 80 as well, it just starts with h2c token instead of h2 token when using port 80. Is there not a cleartext website supporting http/2 yet? (ie. I have to do the ssl way?). That said, this answer is still pretty cool. (why didn't you post it as an answer) – Dean Hiller May 19 '16 at 22:33
  • 1
    One *can* implement `h2c`, but the most web servers supports only `h2` and just redirect `http` traffic to `https`. It's more easy and modern TLS 1.2 implementations support typically ALPN protocol, which simplify the usage of HTTP/2. See [here](http://stackoverflow.com/a/36505907/315935) examples of the typical TLS traffic before the first `h2` packet be sent. – Oleg May 19 '16 at 22:38

1 Answers1

3

The Jetty project implements a HTTP/2 server that can work with both encrypted HTTP/2 and clear-text HTTP/2.

You can easily setup locally a Jetty h2c server with support for direct HTTP/2 communication as well as support for HTTP/1.1 upgrade to HTTP/2.

I recommend you don't bomb a public server with your experiments :)

This is the server code:

public class H2C
{
    public static void main(String[] args) throws Exception
    {
        Server server = new Server();

        HttpConfiguration config = new HttpConfiguration();
        HttpConnectionFactory h1 = new HttpConnectionFactory(config);
        HTTP2CServerConnectionFactory h2 = new HTTP2CServerConnectionFactory(config);
        ServerConnector connector = new ServerConnector(server, h1, h2);
        connector.setPort(8080);
        server.addConnector(connector);

        server.setHandler(new AbstractHandler()
        {
            @Override
            protected void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
            {
                baseRequest.setHandled(true);
                // Your code here.
            }
        });

        server.start();
    }
}

You can use a HTTP/2 client to test the server, such as nghttp, and watch the traffic via Wireshark.

Testing clear-text HTTP/2 via upgrade (using the -u flag, the -v flag is for verbosity):

$ nghttp -uv http://localhost:8080/

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


[  0.001] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols


[  0.001] HTTP Upgrade success
[  0.001] 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.001] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
      (dep_stream_id=0, weight=201, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
      (dep_stream_id=0, weight=101, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
      (dep_stream_id=0, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
      (dep_stream_id=7, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
      (dep_stream_id=3, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
      (dep_stream_id=11, weight=16, exclusive=0)
[  0.001] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.002] recv (stream_id=1) :status: 200
[  0.002] recv (stream_id=1) server: Jetty(9.4.z-SNAPSHOT)
[  0.002] recv (stream_id=1) date: Fri, 20 May 2016 09:38:52 GMT
[  0.002] recv HEADERS frame <length=45, flags=0x05, stream_id=1>
      ; END_STREAM | END_HEADERS
      (padlen=0)
      ; First response header
[  0.002] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
      (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])

Or testing clear-text HTTP/2 directly:

$ nghttp -v http://localhost:8080/

[  0.000] Connected
[  0.000] 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.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
      (dep_stream_id=0, weight=201, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
      (dep_stream_id=0, weight=101, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
      (dep_stream_id=0, weight=1, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
      (dep_stream_id=7, weight=1, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
      (dep_stream_id=3, weight=1, exclusive=0)
[  0.000] send HEADERS frame <length=38, flags=0x25, stream_id=13>
      ; END_STREAM | END_HEADERS | PRIORITY
      (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
      ; Open new stream
      :method: GET
      :path: /
      :scheme: http
      :authority: localhost:8080
      accept: */*
      accept-encoding: gzip, deflate
      user-agent: nghttp2/1.7.1
[  0.095] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.095] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.096] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.105] recv (stream_id=13) :status: 200
[  0.105] recv (stream_id=13) server: Jetty(9.4.z-SNAPSHOT)
[  0.105] recv (stream_id=13) date: Fri, 20 May 2016 09:39:30 GMT
[  0.105] recv HEADERS frame <length=45, flags=0x05, stream_id=13>
      ; END_STREAM | END_HEADERS
      (padlen=0)
      ; First response header
[  0.106] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
      (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
sbordet
  • 16,856
  • 1
  • 50
  • 45