Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-565

http2 doesn't seem to be working

XMLWordPrintable

    • Icon: Documentation Documentation
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 1.2.11.Final
    • SPDY
    • None

      Tried to make http2 work, but chrome tool reports my website is not using http2.
      My website is running both at port 80/443 with self signed certificate which is added to system trusted store. Chrome is not reporting cert error.
      I was checking the chrome tool at chrome://net-internals/#http2 , my url doesn't show up.
      Please see my code and let me know what needs to be done to enable http2?

      My code:
      KeyStore keystore = KeyStore.getInstance("JKS");
      char[] ks_pwd = "password".toCharArray();
      keystore.load(new FileInputStream(System.getProperty("user.dir") + "/ssl/identity.jks"), ks_pwd);
      KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
      kmf.init(keystore, ks_pwd);
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(keystore);
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
      Undertow server = Undertow.builder()
      .setServerOption(UndertowOptions.ENABLE_HTTP2, true)
      .setServerOption(UndertowOptions.ENABLE_SPDY, true)
      .addHttpListener(80, "localhost")
      .addHttpsListener(443, "localhost", sslContext)
      .setHandler(
      path().addExactPath("/", h ->

      { Path HomePage_FileLocation = Paths.get(System.getProperty("user.dir") + "/fe/Home.html"); String Html = String.join("", Files.readAllLines(HomePage_FileLocation)); h.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/html"); h.getResponseSender().send(Html); }

      )
      .addPrefixPath("/r", resource(new FileResourceManager(new File(System.getProperty("user.dir") + "/fe"), 100)).setDirectoryListingEnabled(true))
      .addPrefixPath("/omniws", new WebSocketHandshakeHandler(new WebSocketConnectionCallback() {

      @Override
      public void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel) {
      channel.getReceiveSetter().set(new AbstractReceiveListener() {

      @Override
      protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message)

      { WebSockets.sendText(message.getData(), channel, null); }

      @Override
      protected void onCloseMessage(CloseMessage cm, WebSocketChannel channel)

      { System.out.println("Websocket closed"); }

      });
      channel.resumeReceives();
      }
      }))
      ).build();
      server.start();

            sdouglas1@redhat.com Stuart Douglas
            yananwu Yanan Wu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: