Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-606

HTTP2 framing layer error with HttpCore 5.0 server

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0-beta9
    • 5.0-beta10
    • HttpCore
    • None

    Description

      The attached file implements a simple H2/TLS server that returns a roughly 64 KB response. Things work fine when HTTP1 is used but with HTTP2 a framing layer error is reported.

      Using curl:

      $ curl -k https://localhost:8080/
      curl: (16) Error in the HTTP2 framing layer

      Using Chrome:

      GET https://localhost:8080/ net::ERR_HTTP2_FRAME_SIZE_ERROR 200

      I'm using Conscrypt (org.conscrypt:conscrypt-openjdk-uber:2.2.1) because I currently have only Java 8 environments so that's how I enable H2. I don't know if the bug is related to the JSSE implementation or not. I did try to disable TLS on the server and connect with curl --http2 but that didn't work - curl offered to upgrade but the server returned HTTP1 and the error doesn't happen with HTTP1.

      The response is big enough that writing the response body data to the DataStreamChannel does not consume it all in one call. I believe this might be a factor because if I instead dribble the data out with small writes over time like this then no error occurs:

      private int counter = 0;
      @Override
      public void produce(DataStreamChannel channel) throws IOException {
        if (counter < 4096) {
          ByteBuffer buffer = ByteBuffer.wrap(String.format("%4d:0123456789\n", counter).getBytes());
          counter++;
          channel.write(buffer);
          new Thread(() -> {
            try {
              Thread.sleep(50);
            } catch (InterruptedException ignored) {
      {{      }}}
            channel.requestOutput();
          }).start();
        } else {
          channel.endStream();
      {{  }}}
      }

      To run the test program you will need to modify the code at the beginning of main to load your own X509 KeyStore. Connect to the server with an H2-capable client on port 8080.

      Attachments

        1. ConscryptTest.java
          8 kB
          Roy Hashimoto

        Activity

          People

            Unassigned Unassigned
            rhashimoto Roy Hashimoto
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: