6 Replies Latest reply on May 29, 2015 8:19 PM by ofbizbrazil

    Can we intercept http/2 calls?

    tdanecito

      Hi All,

      Instead of waiting a while for Servlet 4 to be available I am wondering of there is some way to intercept or be the endpoint for http/2 calls using a java program. I still want to use Wildfly 9.0.0.CR1 for regular http 1.0/1.1 calls but I want to be able to add java code to make use of at least http/2 calls. Is there any example of such a thing or something I can modify to do that? I am hoping also to be able to use JSON with it.

       

      Thanks,

      -Tony

        • 1. Re: Can we intercept http/2 calls?
          tdanecito

          I found http2server.java example for what I think I want. Has simple handler. But the http/2 does not seem to be called? I used https in my request but the headers in Firefox seem to indcate http 1.1 instead of h2. Not sure what I need to do to invoke the h2 listener. The code just sets options:

          UndertowOptions.ENABLE_HTTP2, true) .setServerOption(UndertowOptions.ENABLE_SPDY, true)

           

          So I am assuming if this is done say a https://localhost:8443 call from the latest Wildfire or Chrome should call the http/2 listener?

           

          Just trying to get the example working the way I think it should but not 100% sure I am invoking the http/2 listener.

           

          Thanks,

          -Tony

          • 2. Re: Can we intercept http/2 calls?
            ctomc

            did you properly set your jvm to have apln configured http://undertow.io/blog/2015/03/26/HTTP2-In-Wildfly.html

            • 3. Re: Can we intercept http/2 calls?
              tdanecito

              I added the proper apln jar to the project jars (I am running the http2server.java file from eclipse) from eclipse. I did noticed if  did not do that I get an error about not having apln when I run the program.

               

              I also of course have to use 1.8.0_x.  I am using using 1.8.0_45.

               

              Thanks,

              -Tony

              • 4. Re: Can we intercept http/2 calls?
                tdanecito

                I looked over the testing examples to see how it is tested and noticed a custom client was user with uri of "h2" or "h2c". I know http/2 works when used with Wildfly so I am assuming the Undertow example is out of date and missing something. I noted that security realms are set for http/2 for Widlfly but not for the example which I believe is ok since it does use trust and keystores. I did see an odd comment in the Undertow test scripts regarding a problem with priority for http/2 requests and I am wondering if there is a config setting for Undertow to use http/2 before trying http/1.1?

                I will look some more at it tomorrow night.

                 

                Any clues what is wrong will be appreciated. I really think there is something wrong with the http2server.java example like a config setting to force http/2 to be used first. My Wildfly 9.0.0 CR1 is working fine for http/2 just want to go the next step for a lighter hopefully faster setup.

                 

                Regards,

                -Tony

                • 5. Re: Can we intercept http/2 calls?
                  ofbizbrazil

                  Hi all, I am facing the same issue using the code example wirtten, I got a SSL connection but HTTP/2 is not enabled on browser. Tried with 1.2.6 version of undertow nothing has changed. Any news about it?

                   

                  https://github.com/undertow-io/undertow/blob/master/examples/src/main/java/io/undertow/examples/http2/Http2Server.java

                  • 6. Re: Can we intercept http/2 calls?
                    ofbizbrazil

                    Finally, I did it!!!

                    @Bean public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() { final UndertowEmbeddedServletContainerFactory undertowEmbeddedServletContainerFactory = new UndertowEmbeddedServletContainerFactory(); undertowEmbeddedServletContainerFactory .addBuilderCustomizers(new UndertowBuilderCustomizer() { @Override public void customize(final Builder builder) { builder.setServerOption(UndertowOptions.ENABLE_SPDY, true); } }); return undertowEmbeddedServletContainerFactory; } 

                     

                    And do no forget to set in your java execution -Xbootclasspath/p:C:\wildfly-9.0.0.CR1\bin\alpn-boot-8.1.3.v20150130.jar