embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
i have a dillema where my jetty configs led me to a certain configuration but the PushCacheFilter does not work on launch, it throws an NPE. 

i use a restapi that previously inheritted defaultservlet and served the static content itself, and this worked well for PushCacheFilter though i did not want to duplicate the welcomefiles functionality and so refactored to this now.

TIA

```kotlin

package foo.pkg

import org.eclipse.jetty.alpn.server.*
import org.eclipse.jetty.http2.*
import org.eclipse.jetty.http2.server.*
import org.eclipse.jetty.security.*
import org.eclipse.jetty.server.*
import org.eclipse.jetty.server.handler.*
import org.eclipse.jetty.server.handler.gzip.*
import org.eclipse.jetty.servlet.*
import org.eclipse.jetty.util.resource.*
import org.eclipse.jetty.util.security.*
import org.eclipse.jetty.util.security.Constraint.*
import org.eclipse.jetty.util.ssl.*


const val SSL_PORT = 8443

/**
*
*/
class JettyStarter(

/**
*
*/
private vararg val args: String) : AutoCloseable {

private val server: Server = Server().apply {
val httpFactory = HttpConnectionFactory(HttpConfiguration().apply {
addCustomizer(SecureRequestCustomizer())
})
val http2Factory = HTTP2ServerConnectionFactory(HttpConfiguration().apply {
secureScheme = "https"
securePort = SSL_PORT
sendXPoweredBy = false
sendServerVersion = false
addCustomizer(SecureRequestCustomizer())
})
val alpn1 = ALPNServerConnectionFactory().apply {
defaultProtocol = httpFactory.protocol
}
requestLog = AsyncNCSARequestLog()

// HTTP Configuration

connectors = arrayOf(
//Create a connector on port 80 to listen for HTTP requests (that will get redirected)... fail
ServerConnector(this, httpFactory).apply {
setPort(8080)
} ,

ServerConnector(this, SslConnectionFactory(SslContextFactory().apply {
keyStorePath = JettyStarter::class.java.getResource("/keystore").toExternalForm()
setKeyStorePassword("changeit")
cipherComparator = HTTP2Cipher.COMPARATOR
isUseCipherSuitesOrder = true
}, alpn1.protocol),
alpn1,
http2Factory,
httpFactory
).apply { port = SSL_PORT })
//setup the constraint that causes all http requests to return a !403 error

handler = ConstraintSecurityHandler().apply {
//makes the constraint apply to all uri paths
addConstraintMapping(ConstraintMapping().apply {
pathSpec = "/*"
constraint = Constraint().apply { dataConstraint = DC_CONFIDENTIAL }
})
handler = GzipHandler().apply {
handler = ContextHandlerCollection(
ContextHandler().apply {
contextPath = "/"
handler = ResourceHandler().apply {
welcomeFiles = arrayOf("index.html")
baseResource = Resource.newResource(
args.firstOrNull() ?: AdapterServlet.resourceBase.toString())

}
// servletContext.addFilter("push", PushCacheFilter::class.java).apply {
//
//// initParameters = mapOf("maxAssociations" to "32",
//// "ports" to Objects.toString( SSL_PORT )
//// )
// }
//TODO: repair http2 PUSH
// where do I slip this in?

},
ServletContextHandler().apply {
addServlet(AdapterServlet::class.java, "/*")
}

)
}
}


}
@Throws(Exception::class)
fun start() {
server.start()
}
@Throws(Exception::class)
override fun close() {
server.stop()
}


}
```

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Simone Bordet-3
Hi,

On Wed, Feb 13, 2019 at 11:01 AM James Northrup <[hidden email]> wrote:
>
> i have a dillema where my jetty configs led me to a certain configuration but the PushCacheFilter does not work on launch, it throws an NPE.

Jetty version?
Stack trace of the NPE?

> i use a restapi that previously inheritted defaultservlet and served the static content itself, and this worked well for PushCacheFilter though i did not want to duplicate the welcomefiles functionality and so refactored to this now.

Code seems ok, provided you uncomment the PushCacheFilter.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
this is the uncommented outome 

Server@732f6050{STOPPED}[9.4.14.v20181114]

12:00:07.222 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - o.e.j.s.h.ContextHandler@20eaeaf8{/,null,UNAVAILABLE} added {ResourceHandler@748ac6f3{STOPPED},MANAGED}
12:00:07.223 [main] WARN org.eclipse.jetty.server.handler.ContextHandler - Unimplemented - use org.eclipse.jetty.servlet.ServletContextHandlerException in thread "main" java.lang.NullPointerException at id.kbr.prime.JettyStarter.<init>(JettyStarter.kt:86)

 
i read, and re-read the jetty examples for embedding and tried to infer the simplest one that could add http2/push with static, a rest api, and gzip.  i feel like there's a linkage or an explanation page for all this that's not among the quickstart



On Wed, Feb 13, 2019 at 6:06 PM Simone Bordet <[hidden email]> wrote:
Hi,

On Wed, Feb 13, 2019 at 11:01 AM James Northrup <[hidden email]> wrote:
>
> i have a dillema where my jetty configs led me to a certain configuration but the PushCacheFilter does not work on launch, it throws an NPE.

Jetty version?
Stack trace of the NPE?

> i use a restapi that previously inheritted defaultservlet and served the static content itself, and this worked well for PushCacheFilter though i did not want to duplicate the welcomefiles functionality and so refactored to this now.

Code seems ok, provided you uncomment the PushCacheFilter.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

class JettyStarter(

        /**
         *
         */
        private vararg val args: String) : AutoCloseable {

    private val server: Server =

            Server().apply {
                val httpFactory = HttpConnectionFactory(HttpConfiguration().apply {
                    addCustomizer(SecureRequestCustomizer())
                })
                val http2Factory = HTTP2ServerConnectionFactory(HttpConfiguration().apply {
                    secureScheme = "https"
                    securePort = SSL_PORT
                    sendXPoweredBy = false
                    sendServerVersion = false
                    addCustomizer(SecureRequestCustomizer())
                })
                val alpn1 = ALPNServerConnectionFactory().apply {
                    defaultProtocol = httpFactory.protocol
                }
                requestLog = AsyncNCSARequestLog()

                // HTTP Configuration

                connectors = arrayOf(
                        //Create a connector on port 80 to listen for HTTP requests (that will get redirected)... fail
                        ServerConnector(this, httpFactory).apply {
                            setPort(8080)
                        },

                        ServerConnector(this, SslConnectionFactory(SslContextFactory().apply {
                            keyStorePath = JettyStarter::class.java.getResource("/keystore").toExternalForm()
                            setKeyStorePassword("changeit")
                            cipherComparator = HTTP2Cipher.COMPARATOR
                            isUseCipherSuitesOrder = true
                        }, alpn1.protocol),
                                        alpn1,
                                        http2Factory,
                                        httpFactory
                        ).apply { port = SSL_PORT })
                //setup the constraint that causes all http requests to return a !403 error

                handler = ConstraintSecurityHandler().apply {
                    //makes the constraint apply to all uri paths
                    addConstraintMapping(ConstraintMapping().apply {
                        pathSpec = "/*"
                        constraint = Constraint().apply { dataConstraint = DC_CONFIDENTIAL }
                    })
                    handler = GzipHandler().apply {
                        handler = ContextHandlerCollection(
                                org.eclipse.jetty.servlet.ServletContextHandler().apply {
                                    contextPath = "/"
                                    handler = ResourceHandler().apply {
                                        welcomeFiles = arrayOf("index.html")
                                        baseResource = Resource.newResource(
                                                args.firstOrNull() ?: AdapterServlet.resourceBase.toString())

                                    }
                                servletContext.addFilter("push", PushCacheFilter::class.java).apply {
                                    initParameters = mapOf("maxAssociations" to "32",
                                                           "ports" to Objects.toString(SSL_PORT )
                                    )
                                }
                                    //TODO: repair http2 PUSH
                                    // where do I slip this in?

                                },
                                ServletContextHandler().apply {
                                    addServlet(AdapterServlet::class.java, "/*")
                                }

                        )
                    }
                }


            }

    /**
     *
     */
    @Throws(Exception::class)
    fun start() {
        server.start()
    }

    /**
     *
     */
    @Throws(Exception::class)
    override fun close() {
        server.stop()
    } 
}



On Fri, Feb 15, 2019 at 12:21 PM James Northrup <[hidden email]> wrote:
this is the uncommented outome 

Server@732f6050{STOPPED}[9.4.14.v20181114]

12:00:07.222 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - o.e.j.s.h.ContextHandler@20eaeaf8{/,null,UNAVAILABLE} added {ResourceHandler@748ac6f3{STOPPED},MANAGED}
12:00:07.223 [main] WARN org.eclipse.jetty.server.handler.ContextHandler - Unimplemented - use org.eclipse.jetty.servlet.ServletContextHandlerException in thread "main" java.lang.NullPointerException at id.kbr.prime.JettyStarter.<init>(JettyStarter.kt:86)

 
i read, and re-read the jetty examples for embedding and tried to infer the simplest one that could add http2/push with static, a rest api, and gzip.  i feel like there's a linkage or an explanation page for all this that's not among the quickstart



On Wed, Feb 13, 2019 at 6:06 PM Simone Bordet <[hidden email]> wrote:
Hi,

On Wed, Feb 13, 2019 at 11:01 AM James Northrup <[hidden email]> wrote:
>
> i have a dillema where my jetty configs led me to a certain configuration but the PushCacheFilter does not work on launch, it throws an NPE.

Jetty version?
Stack trace of the NPE?

> i use a restapi that previously inheritted defaultservlet and served the static content itself, and this worked well for PushCacheFilter though i did not want to duplicate the welcomefiles functionality and so refactored to this now.

Code seems ok, provided you uncomment the PushCacheFilter.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Simone Bordet-3
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup

On Fri, Feb 15, 2019 at 2:59 PM Simone Bordet <[hidden email]> wrote:
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
im building the java bootstrap code as requested as well, to test.  in my educated opinion its going to be an unexpected kotlin error if Pushcachefilter succeeds with the identical java code.

my goal is not to hammer the likeness of this code into existence through force of willpower, just to meet the laundry list of reasonable PWA+http2 expectations in the subject lines, for which none of the samples seem to cater in one place (i had to exrrapolate from two or three samples for this failure condition)

since this codebase uses a hazelcast mesh, i really want the simplest possible formula to launch an instance.  






 

On Sun, Feb 17, 2019 at 11:54 AM James Northrup <[hidden email]> wrote:

On Fri, Feb 15, 2019 at 2:59 PM Simone Bordet <[hidden email]> wrote:
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
In reply to this post by James Northrup

at id.kbr.prime.JettyJavaStarter.main(JettyJavaStarter.java:111)
Suppressed: java.lang.NullPointerException
at org.eclipse.jetty.servlets.PushCacheFilter.init(PushCacheFilter.java:114)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)


again, whatever I'm doing is just uninformed guesswork from incomplete knowledge.  the reason for various features is to support 100/100 lighthouse score on hnpwa or thereabouts.

roughly speaking, jetty should be able to host e.g. https://github.com/dsolimando/hnpwa-mobileelements  with http2-push as designed.  adding an additional rest-api is the tweak you need to be able to drive the static content with java backend frameworks .





On Sun, Feb 17, 2019 at 11:54 AM James Northrup <[hidden email]> wrote:

On Fri, Feb 15, 2019 at 2:59 PM Simone Bordet <[hidden email]> wrote:
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
hi Simone, 

just checking in.

i just wanted to pose a question:
the java code at the bottom of this email is somewhat hard to follow.  is this the most succinct programatic way to create the desired h2 server, static, api, and gzip ?

this still fails with pushcachefilter, as well highlighted in the previous gist..  

package id.kbr.prime;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.http2.HTTP2Cipher;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlets.PushCacheFilter;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import javax.servlet.FilterRegistration;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.TreeMap;
import static id.kbr.prime.JettyStarterKt.SSL_PORT;
import static org.apache.commons.lang3.ArrayUtils.toArray;
public class JettyJavaStarter implements AutoCloseable {
private final Server server;
public JettyJavaStarter(String... args) {
server = new Server() {
{
HttpConnectionFactory httpFactory = new HttpConnectionFactory(new HttpConfiguration() {{
addCustomizer(new SecureRequestCustomizer());
}});
HTTP2ServerConnectionFactory http2factory = new HTTP2ServerConnectionFactory(new HttpConfiguration() {{
setSecureScheme("https");
setSecurePort(SSL_PORT);
setSendXPoweredBy(false);
setSendServerVersion(false);
addCustomizer(new SecureRequestCustomizer());
}});
ALPNServerConnectionFactory alpn1 = new ALPNServerConnectionFactory() {{
setDefaultProtocol(httpFactory.getProtocol());
}};
setRequestLog(new AsyncNCSARequestLog());
setConnectors(
new Connector[]{
new ServerConnector(this, httpFactory) {{
setPort(8080);
}},
new ServerConnector(this, new SslConnectionFactory(new SslContextFactory() {{
setKeyStorePath(JettyStarter.class.getResource("/keystore").toExternalForm());
setCipherComparator(HTTP2Cipher.COMPARATOR);
setKeyStorePassword("changeit");
setUseCipherSuitesOrder(true);
}}, alpn1.getProtocol()), http2factory, httpFactory) {{
setPort(SSL_PORT);
}}
}
);
setHandler(new ConstraintSecurityHandler() {{
addConstraintMapping(new ConstraintMapping() {{
setPathSpec("/*");
setConstraint(new Constraint() {{
setDataConstraint(DC_CONFIDENTIAL);
}});
setHandler(new GzipHandler() {{
setHandler(new ContextHandlerCollection(new ServletContextHandler() {{
setContextPath("/");
setHandler(new ResourceHandler() {{
setWelcomeFiles(toArray("index.html"));
setBaseResource(Resource.newResource(Paths.get(args.length > 0 ? args[0] : AdapterServlet.Companion.getResourceBase().toString())));
}});
//the main feature: pass or fail?
FilterRegistration.Dynamic push = getServletContext().addFilter("push", PushCacheFilter.class);
push.setInitParameters(new HashMap<String, String>() {{
put("maxAssociations", "" + 32);
put("ports", "" + SSL_PORT);
}});
}},
new ServletContextHandler() {{
addServlet(AdapterServlet.class, "/*");
}}
));
}});
}});
}});
}
};
}
public void start() throws Exception {
server.start();
}
@Override
public void close() throws Exception {
server.stop();
}
public static void main(String... args) throws Exception {
AppKt.hz = Hazelcast.getOrCreateHazelcastInstance(new Config(args.length > 1 ? args[1] : "default"));
JettyJavaStarter it = new JettyJavaStarter(args);
it.start();
synchronized (it) {
it.wait();
}
}
}

On Sun, Feb 17, 2019 at 1:28 PM James Northrup <[hidden email]> wrote:

at id.kbr.prime.JettyJavaStarter.main(JettyJavaStarter.java:111)
Suppressed: java.lang.NullPointerException
at org.eclipse.jetty.servlets.PushCacheFilter.init(PushCacheFilter.java:114)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)


again, whatever I'm doing is just uninformed guesswork from incomplete knowledge.  the reason for various features is to support 100/100 lighthouse score on hnpwa or thereabouts.

roughly speaking, jetty should be able to host e.g. https://github.com/dsolimando/hnpwa-mobileelements  with http2-push as designed.  adding an additional rest-api is the tweak you need to be able to drive the static content with java backend frameworks .





On Sun, Feb 17, 2019 at 11:54 AM James Northrup <[hidden email]> wrote:

On Fri, Feb 15, 2019 at 2:59 PM Simone Bordet <[hidden email]> wrote:
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Joakim Erdfelt-8
There's a few shortcuts you are taking that are not helping you.
  • HttpConfiguration isn't 100% common between connectors, use the hierarchy.
  • ServerRequestCustomizer only belongs on secure connector
  • SecureScheme / SecurePort configuration belongs on non-secure connector
  • Constraints / ConstraintMappings are not needed if you use the SecureRedirectHandler
  • You shouldn't need to wrap handlers as much as you are doing.
  • ResourceHandler is a poor choice for within a ServletContextHandler (it's designed to be used with DefaultServlet, not a ResourceHandler)
  • ServletContextHandler should have a BaseResource setup, many things use it. (various Servlet APIs and also the DefaultServlet)
  • A BaseResource can be directly created from a java Path, use a PathResource
etc ...

Here's a broken down version of what you are attempting to do, with proper initialization and configuration.

        Server server = new Server();

        // HTTP Port

        HttpConfiguration httpConfig = new HttpConfiguration();
        httpConfig.setSecureScheme("https"); // needed on non-ssl connector for secure redirect
        httpConfig.setSecurePort(SSL_PORT); // needed on non-ssl connector for secure redirect
        httpConfig.setSendXPoweredBy(false);
        httpConfig.setSendServerVersion(false);

        HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory();
        ServerConnector httpConnector = new ServerConnector(server, httpConnectionFactory);
        httpConnector.setPort(8080);
        server.addConnector(httpConnector);

        // TLS (SSL) Port

        HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); // extends from non-ssl
        httpsConfig.addCustomizer(new SecureRequestCustomizer()); // only valid on SSL/TLS connector

        HTTP2ServerConnectionFactory http2ConnectionFactory = new HTTP2ServerConnectionFactory(httpsConfig);
        ALPNServerConnectionFactory alpnConnectionFactory = new ALPNServerConnectionFactory();
        alpnConnectionFactory.setDefaultProtocol(httpConnectionFactory.getProtocol());
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStorePath(GzipHttp2PushFilterExample.class.getResource("/keystore").toExternalForm());
        sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
        sslContextFactory.setKeyStorePassword("changeit");
        sslContextFactory.setUseCipherSuitesOrder(true);
        SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, alpnConnectionFactory.getProtocol());
        ServerConnector httpsConnector = new ServerConnector(server, sslConnectionFactory, http2ConnectionFactory,  httpConnectionFactory);

        server.addConnector(httpsConnector);

        // Non Handler Configuration
        server.setRequestLog(new AsyncNCSARequestLog());

        // Servlet ROOT Context
        ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        context.setWelcomeFiles(new String[]{"index.html"});
        context.setBaseResource(new PathResource(Paths.get("some","path", "somewhere")));

        // Push Cache Filter
        FilterHolder pushFilter = context.addFilter(PushCacheFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        pushFilter.setInitParameter("maxAssociations", "" + 32);
        pushFilter.setInitParameter("ports", "" + SSL_PORT);

        // Your servlet
        context.addServlet(AdapterServlet.class, "/*"); // won't serve static files if you use this url-pattern!

        // what serves static files from a ServletContext, always added last
        ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class); // always named "default"
        defHolder.setInitParameter("dirAllowed", "false");
        context.addServlet(defHolder, "/"); // always at url-pattern "/"

        // Handler Tree
        HandlerList handlers = new HandlerList();
        handlers.addHandler(new SecuredRedirectHandler()); // no need for Constraints / Constraint Mappings
        handlers.addHandler(new GzipHandler()); // wrapping / nesting is optional
        handlers.addHandler(context);
        handlers.addHandler(new DefaultHandler()); // always last in handler tree, to help with errors and configuration mistakes

        server.setHandler(handlers);


Joakim Erdfelt / [hidden email]


On Mon, Feb 18, 2019 at 9:38 AM James Northrup <[hidden email]> wrote:
hi Simone, 

just checking in.

i just wanted to pose a question:
the java code at the bottom of this email is somewhat hard to follow.  is this the most succinct programatic way to create the desired h2 server, static, api, and gzip ?

this still fails with pushcachefilter, as well highlighted in the previous gist..  

package id.kbr.prime;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.http2.HTTP2Cipher;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlets.PushCacheFilter;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import javax.servlet.FilterRegistration;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.TreeMap;
import static id.kbr.prime.JettyStarterKt.SSL_PORT;
import static org.apache.commons.lang3.ArrayUtils.toArray;
public class JettyJavaStarter implements AutoCloseable {
private final Server server;
public JettyJavaStarter(String... args) {
server = new Server() {
{
HttpConnectionFactory httpFactory = new HttpConnectionFactory(new HttpConfiguration() {{
addCustomizer(new SecureRequestCustomizer());
}});
HTTP2ServerConnectionFactory http2factory = new HTTP2ServerConnectionFactory(new HttpConfiguration() {{
setSecureScheme("https");
setSecurePort(SSL_PORT);
setSendXPoweredBy(false);
setSendServerVersion(false);
addCustomizer(new SecureRequestCustomizer());
}});
ALPNServerConnectionFactory alpn1 = new ALPNServerConnectionFactory() {{
setDefaultProtocol(httpFactory.getProtocol());
}};
setRequestLog(new AsyncNCSARequestLog());
setConnectors(
new Connector[]{
new ServerConnector(this, httpFactory) {{
setPort(8080);
}},
new ServerConnector(this, new SslConnectionFactory(new SslContextFactory() {{
setKeyStorePath(JettyStarter.class.getResource("/keystore").toExternalForm());
setCipherComparator(HTTP2Cipher.COMPARATOR);
setKeyStorePassword("changeit");
setUseCipherSuitesOrder(true);
}}, alpn1.getProtocol()), http2factory, httpFactory) {{
setPort(SSL_PORT);
}}
}
);
setHandler(new ConstraintSecurityHandler() {{
addConstraintMapping(new ConstraintMapping() {{
setPathSpec("/*");
setConstraint(new Constraint() {{
setDataConstraint(DC_CONFIDENTIAL);
}});
setHandler(new GzipHandler() {{
setHandler(new ContextHandlerCollection(new ServletContextHandler() {{
setContextPath("/");
setHandler(new ResourceHandler() {{
setWelcomeFiles(toArray("index.html"));
setBaseResource(Resource.newResource(Paths.get(args.length > 0 ? args[0] : AdapterServlet.Companion.getResourceBase().toString())));
}});
//the main feature: pass or fail?
FilterRegistration.Dynamic push = getServletContext().addFilter("push", PushCacheFilter.class);
push.setInitParameters(new HashMap<String, String>() {{
put("maxAssociations", "" + 32);
put("ports", "" + SSL_PORT);
}});
}},
new ServletContextHandler() {{
addServlet(AdapterServlet.class, "/*");
}}
));
}});
}});
}});
}
};
}
public void start() throws Exception {
server.start();
}
@Override
public void close() throws Exception {
server.stop();
}
public static void main(String... args) throws Exception {
AppKt.hz = Hazelcast.getOrCreateHazelcastInstance(new Config(args.length > 1 ? args[1] : "default"));
JettyJavaStarter it = new JettyJavaStarter(args);
it.start();
synchronized (it) {
it.wait();
}
}
}

On Sun, Feb 17, 2019 at 1:28 PM James Northrup <[hidden email]> wrote:

at id.kbr.prime.JettyJavaStarter.main(JettyJavaStarter.java:111)
Suppressed: java.lang.NullPointerException
at org.eclipse.jetty.servlets.PushCacheFilter.init(PushCacheFilter.java:114)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)


again, whatever I'm doing is just uninformed guesswork from incomplete knowledge.  the reason for various features is to support 100/100 lighthouse score on hnpwa or thereabouts.

roughly speaking, jetty should be able to host e.g. https://github.com/dsolimando/hnpwa-mobileelements  with http2-push as designed.  adding an additional rest-api is the tweak you need to be able to drive the static content with java backend frameworks .





On Sun, Feb 17, 2019 at 11:54 AM James Northrup <[hidden email]> wrote:

On Fri, Feb 15, 2019 at 2:59 PM Simone Bordet <[hidden email]> wrote:
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
Joakim I am _so_ appreciative you gave this a look and reiterated my fumbling attempts.  thank you so much!  I'd like to gain the familiarity you are demonstrating, but chances are if it works I might never revisit this again!

perhaps you might make a small jetty docs page for PWA and AMP hosting that puts emphasis on the site performance metrics along these lines.  the sample materials I have pulled from thus far have spanned early jetty 8.x thru now to cover the breadth of h2/push/gzip/api/static. 

Thanks!

On Mon, Feb 18, 2019 at 10:23 PM Joakim Erdfelt <[hidden email]> wrote:
There's a few shortcuts you are taking that are not helping you.
  • HttpConfiguration isn't 100% common between connectors, use the hierarchy.
  • ServerRequestCustomizer only belongs on secure connector
  • SecureScheme / SecurePort configuration belongs on non-secure connector
  • Constraints / ConstraintMappings are not needed if you use the SecureRedirectHandler
  • You shouldn't need to wrap handlers as much as you are doing.
  • ResourceHandler is a poor choice for within a ServletContextHandler (it's designed to be used with DefaultServlet, not a ResourceHandler)
  • ServletContextHandler should have a BaseResource setup, many things use it. (various Servlet APIs and also the DefaultServlet)
  • A BaseResource can be directly created from a java Path, use a PathResource
etc ...

Here's a broken down version of what you are attempting to do, with proper initialization and configuration.

        Server server = new Server();

        // HTTP Port

        HttpConfiguration httpConfig = new HttpConfiguration();
        httpConfig.setSecureScheme("https"); // needed on non-ssl connector for secure redirect
        httpConfig.setSecurePort(SSL_PORT); // needed on non-ssl connector for secure redirect
        httpConfig.setSendXPoweredBy(false);
        httpConfig.setSendServerVersion(false);

        HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory();
        ServerConnector httpConnector = new ServerConnector(server, httpConnectionFactory);
        httpConnector.setPort(8080);
        server.addConnector(httpConnector);

        // TLS (SSL) Port

        HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); // extends from non-ssl
        httpsConfig.addCustomizer(new SecureRequestCustomizer()); // only valid on SSL/TLS connector

        HTTP2ServerConnectionFactory http2ConnectionFactory = new HTTP2ServerConnectionFactory(httpsConfig);
        ALPNServerConnectionFactory alpnConnectionFactory = new ALPNServerConnectionFactory();
        alpnConnectionFactory.setDefaultProtocol(httpConnectionFactory.getProtocol());
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStorePath(GzipHttp2PushFilterExample.class.getResource("/keystore").toExternalForm());
        sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
        sslContextFactory.setKeyStorePassword("changeit");
        sslContextFactory.setUseCipherSuitesOrder(true);
        SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, alpnConnectionFactory.getProtocol());
        ServerConnector httpsConnector = new ServerConnector(server, sslConnectionFactory, http2ConnectionFactory,  httpConnectionFactory);

        server.addConnector(httpsConnector);

        // Non Handler Configuration
        server.setRequestLog(new AsyncNCSARequestLog());

        // Servlet ROOT Context
        ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        context.setWelcomeFiles(new String[]{"index.html"});
        context.setBaseResource(new PathResource(Paths.get("some","path", "somewhere")));

        // Push Cache Filter
        FilterHolder pushFilter = context.addFilter(PushCacheFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        pushFilter.setInitParameter("maxAssociations", "" + 32);
        pushFilter.setInitParameter("ports", "" + SSL_PORT);

        // Your servlet
        context.addServlet(AdapterServlet.class, "/*"); // won't serve static files if you use this url-pattern!

        // what serves static files from a ServletContext, always added last
        ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class); // always named "default"
        defHolder.setInitParameter("dirAllowed", "false");
        context.addServlet(defHolder, "/"); // always at url-pattern "/"

        // Handler Tree
        HandlerList handlers = new HandlerList();
        handlers.addHandler(new SecuredRedirectHandler()); // no need for Constraints / Constraint Mappings
        handlers.addHandler(new GzipHandler()); // wrapping / nesting is optional
        handlers.addHandler(context);
        handlers.addHandler(new DefaultHandler()); // always last in handler tree, to help with errors and configuration mistakes

        server.setHandler(handlers);


Joakim Erdfelt / [hidden email]


On Mon, Feb 18, 2019 at 9:38 AM James Northrup <[hidden email]> wrote:
hi Simone, 

just checking in.

i just wanted to pose a question:
the java code at the bottom of this email is somewhat hard to follow.  is this the most succinct programatic way to create the desired h2 server, static, api, and gzip ?

this still fails with pushcachefilter, as well highlighted in the previous gist..  

package id.kbr.prime;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.http2.HTTP2Cipher;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlets.PushCacheFilter;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import javax.servlet.FilterRegistration;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.TreeMap;
import static id.kbr.prime.JettyStarterKt.SSL_PORT;
import static org.apache.commons.lang3.ArrayUtils.toArray;
public class JettyJavaStarter implements AutoCloseable {
private final Server server;
public JettyJavaStarter(String... args) {
server = new Server() {
{
HttpConnectionFactory httpFactory = new HttpConnectionFactory(new HttpConfiguration() {{
addCustomizer(new SecureRequestCustomizer());
}});
HTTP2ServerConnectionFactory http2factory = new HTTP2ServerConnectionFactory(new HttpConfiguration() {{
setSecureScheme("https");
setSecurePort(SSL_PORT);
setSendXPoweredBy(false);
setSendServerVersion(false);
addCustomizer(new SecureRequestCustomizer());
}});
ALPNServerConnectionFactory alpn1 = new ALPNServerConnectionFactory() {{
setDefaultProtocol(httpFactory.getProtocol());
}};
setRequestLog(new AsyncNCSARequestLog());
setConnectors(
new Connector[]{
new ServerConnector(this, httpFactory) {{
setPort(8080);
}},
new ServerConnector(this, new SslConnectionFactory(new SslContextFactory() {{
setKeyStorePath(JettyStarter.class.getResource("/keystore").toExternalForm());
setCipherComparator(HTTP2Cipher.COMPARATOR);
setKeyStorePassword("changeit");
setUseCipherSuitesOrder(true);
}}, alpn1.getProtocol()), http2factory, httpFactory) {{
setPort(SSL_PORT);
}}
}
);
setHandler(new ConstraintSecurityHandler() {{
addConstraintMapping(new ConstraintMapping() {{
setPathSpec("/*");
setConstraint(new Constraint() {{
setDataConstraint(DC_CONFIDENTIAL);
}});
setHandler(new GzipHandler() {{
setHandler(new ContextHandlerCollection(new ServletContextHandler() {{
setContextPath("/");
setHandler(new ResourceHandler() {{
setWelcomeFiles(toArray("index.html"));
setBaseResource(Resource.newResource(Paths.get(args.length > 0 ? args[0] : AdapterServlet.Companion.getResourceBase().toString())));
}});
//the main feature: pass or fail?
FilterRegistration.Dynamic push = getServletContext().addFilter("push", PushCacheFilter.class);
push.setInitParameters(new HashMap<String, String>() {{
put("maxAssociations", "" + 32);
put("ports", "" + SSL_PORT);
}});
}},
new ServletContextHandler() {{
addServlet(AdapterServlet.class, "/*");
}}
));
}});
}});
}});
}
};
}
public void start() throws Exception {
server.start();
}
@Override
public void close() throws Exception {
server.stop();
}
public static void main(String... args) throws Exception {
AppKt.hz = Hazelcast.getOrCreateHazelcastInstance(new Config(args.length > 1 ? args[1] : "default"));
JettyJavaStarter it = new JettyJavaStarter(args);
it.start();
synchronized (it) {
it.wait();
}
}
}

On Sun, Feb 17, 2019 at 1:28 PM James Northrup <[hidden email]> wrote:

at id.kbr.prime.JettyJavaStarter.main(JettyJavaStarter.java:111)
Suppressed: java.lang.NullPointerException
at org.eclipse.jetty.servlets.PushCacheFilter.init(PushCacheFilter.java:114)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)


again, whatever I'm doing is just uninformed guesswork from incomplete knowledge.  the reason for various features is to support 100/100 lighthouse score on hnpwa or thereabouts.

roughly speaking, jetty should be able to host e.g. https://github.com/dsolimando/hnpwa-mobileelements  with http2-push as designed.  adding an additional rest-api is the tweak you need to be able to drive the static content with java backend frameworks .





On Sun, Feb 17, 2019 at 11:54 AM James Northrup <[hidden email]> wrote:

On Fri, Feb 15, 2019 at 2:59 PM Simone Bordet <[hidden email]> wrote:
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
two permutations of this fail to launch/serve 


copying exactly into a java launcher, i get 

Exception in thread "main" java.lang.IllegalStateException: No protocol factory for SSL next protocol: 'alpn' in ServerConnector@3bd82cf5{SSL,[ssl, h2, http/1.1]}{0.0.0.0:34131}
13:00:40.637 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - ServerConnector@158d2680{SSL,[ssl, h2, http/1.1]}{0.0.0.0:33379} added {sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:33379],POJO}
13:00:40.637 [qtp341878976-35] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - run acceptor-1@51c668e3
13:00:40.639 [main] WARN org.eclipse.jetty.util.component.AbstractLifeCycle - FAILED ServerConnector@158d2680{SSL,[ssl, h2, http/1.1]}{0.0.0.0:33379}: java.lang.IllegalStateException: No protocol factory for SSL next protocol: 'alpn' in ServerConnector@158d2680{SSL,[ssl, h2, http/1.1]}{0.0.0.0:33379}
java.lang.IllegalStateException: No protocol factory for SSL next protocol: 'alpn' in ServerConnector@158d2680{SSL,[ssl, h2, http/1.1]}{0.0.0.0:33379}
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:278)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:394)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at id.kbr.prime.JavaJettyStarter.start(JavaJettyStarter.java:95)
at id.kbr.prime.JavaJettyStarter.main(JavaJettyStarter.java:106)



changing to:
SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, alpnConnectionFactory.getProtocol());
ServerConnector httpsConnector = new ServerConnector(server, sslConnectionFactory, alpnConnectionFactory,http2ConnectionFactory, httpConnectionFactory);
httpsConnector.setPort(SSL_PORT);
becomes:
https://gist.github.com/jnorthrup/1ee1974e45ae387663e9f49843b05cf6
(launcher code included below the log)


On Mon, Feb 18, 2019 at 11:54 PM James Northrup <[hidden email]> wrote:
Joakim I am _so_ appreciative you gave this a look and reiterated my fumbling attempts.  thank you so much!  I'd like to gain the familiarity you are demonstrating, but chances are if it works I might never revisit this again!

perhaps you might make a small jetty docs page for PWA and AMP hosting that puts emphasis on the site performance metrics along these lines.  the sample materials I have pulled from thus far have spanned early jetty 8.x thru now to cover the breadth of h2/push/gzip/api/static. 

Thanks!

On Mon, Feb 18, 2019 at 10:23 PM Joakim Erdfelt <[hidden email]> wrote:
There's a few shortcuts you are taking that are not helping you.
  • HttpConfiguration isn't 100% common between connectors, use the hierarchy.
  • ServerRequestCustomizer only belongs on secure connector
  • SecureScheme / SecurePort configuration belongs on non-secure connector
  • Constraints / ConstraintMappings are not needed if you use the SecureRedirectHandler
  • You shouldn't need to wrap handlers as much as you are doing.
  • ResourceHandler is a poor choice for within a ServletContextHandler (it's designed to be used with DefaultServlet, not a ResourceHandler)
  • ServletContextHandler should have a BaseResource setup, many things use it. (various Servlet APIs and also the DefaultServlet)
  • A BaseResource can be directly created from a java Path, use a PathResource
etc ...

Here's a broken down version of what you are attempting to do, with proper initialization and configuration.

        Server server = new Server();

        // HTTP Port

        HttpConfiguration httpConfig = new HttpConfiguration();
        httpConfig.setSecureScheme("https"); // needed on non-ssl connector for secure redirect
        httpConfig.setSecurePort(SSL_PORT); // needed on non-ssl connector for secure redirect
        httpConfig.setSendXPoweredBy(false);
        httpConfig.setSendServerVersion(false);

        HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory();
        ServerConnector httpConnector = new ServerConnector(server, httpConnectionFactory);
        httpConnector.setPort(8080);
        server.addConnector(httpConnector);

        // TLS (SSL) Port

        HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); // extends from non-ssl
        httpsConfig.addCustomizer(new SecureRequestCustomizer()); // only valid on SSL/TLS connector

        HTTP2ServerConnectionFactory http2ConnectionFactory = new HTTP2ServerConnectionFactory(httpsConfig);
        ALPNServerConnectionFactory alpnConnectionFactory = new ALPNServerConnectionFactory();
        alpnConnectionFactory.setDefaultProtocol(httpConnectionFactory.getProtocol());
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStorePath(GzipHttp2PushFilterExample.class.getResource("/keystore").toExternalForm());
        sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
        sslContextFactory.setKeyStorePassword("changeit");
        sslContextFactory.setUseCipherSuitesOrder(true);
        SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, alpnConnectionFactory.getProtocol());
        ServerConnector httpsConnector = new ServerConnector(server, sslConnectionFactory, http2ConnectionFactory,  httpConnectionFactory);

        server.addConnector(httpsConnector);

        // Non Handler Configuration
        server.setRequestLog(new AsyncNCSARequestLog());

        // Servlet ROOT Context
        ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        context.setWelcomeFiles(new String[]{"index.html"});
        context.setBaseResource(new PathResource(Paths.get("some","path", "somewhere")));

        // Push Cache Filter
        FilterHolder pushFilter = context.addFilter(PushCacheFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        pushFilter.setInitParameter("maxAssociations", "" + 32);
        pushFilter.setInitParameter("ports", "" + SSL_PORT);

        // Your servlet
        context.addServlet(AdapterServlet.class, "/*"); // won't serve static files if you use this url-pattern!

        // what serves static files from a ServletContext, always added last
        ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class); // always named "default"
        defHolder.setInitParameter("dirAllowed", "false");
        context.addServlet(defHolder, "/"); // always at url-pattern "/"

        // Handler Tree
        HandlerList handlers = new HandlerList();
        handlers.addHandler(new SecuredRedirectHandler()); // no need for Constraints / Constraint Mappings
        handlers.addHandler(new GzipHandler()); // wrapping / nesting is optional
        handlers.addHandler(context);
        handlers.addHandler(new DefaultHandler()); // always last in handler tree, to help with errors and configuration mistakes

        server.setHandler(handlers);


Joakim Erdfelt / [hidden email]


On Mon, Feb 18, 2019 at 9:38 AM James Northrup <[hidden email]> wrote:
hi Simone, 

just checking in.

i just wanted to pose a question:
the java code at the bottom of this email is somewhat hard to follow.  is this the most succinct programatic way to create the desired h2 server, static, api, and gzip ?

this still fails with pushcachefilter, as well highlighted in the previous gist..  

package id.kbr.prime;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.http2.HTTP2Cipher;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlets.PushCacheFilter;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import javax.servlet.FilterRegistration;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.TreeMap;
import static id.kbr.prime.JettyStarterKt.SSL_PORT;
import static org.apache.commons.lang3.ArrayUtils.toArray;
public class JettyJavaStarter implements AutoCloseable {
private final Server server;
public JettyJavaStarter(String... args) {
server = new Server() {
{
HttpConnectionFactory httpFactory = new HttpConnectionFactory(new HttpConfiguration() {{
addCustomizer(new SecureRequestCustomizer());
}});
HTTP2ServerConnectionFactory http2factory = new HTTP2ServerConnectionFactory(new HttpConfiguration() {{
setSecureScheme("https");
setSecurePort(SSL_PORT);
setSendXPoweredBy(false);
setSendServerVersion(false);
addCustomizer(new SecureRequestCustomizer());
}});
ALPNServerConnectionFactory alpn1 = new ALPNServerConnectionFactory() {{
setDefaultProtocol(httpFactory.getProtocol());
}};
setRequestLog(new AsyncNCSARequestLog());
setConnectors(
new Connector[]{
new ServerConnector(this, httpFactory) {{
setPort(8080);
}},
new ServerConnector(this, new SslConnectionFactory(new SslContextFactory() {{
setKeyStorePath(JettyStarter.class.getResource("/keystore").toExternalForm());
setCipherComparator(HTTP2Cipher.COMPARATOR);
setKeyStorePassword("changeit");
setUseCipherSuitesOrder(true);
}}, alpn1.getProtocol()), http2factory, httpFactory) {{
setPort(SSL_PORT);
}}
}
);
setHandler(new ConstraintSecurityHandler() {{
addConstraintMapping(new ConstraintMapping() {{
setPathSpec("/*");
setConstraint(new Constraint() {{
setDataConstraint(DC_CONFIDENTIAL);
}});
setHandler(new GzipHandler() {{
setHandler(new ContextHandlerCollection(new ServletContextHandler() {{
setContextPath("/");
setHandler(new ResourceHandler() {{
setWelcomeFiles(toArray("index.html"));
setBaseResource(Resource.newResource(Paths.get(args.length > 0 ? args[0] : AdapterServlet.Companion.getResourceBase().toString())));
}});
//the main feature: pass or fail?
FilterRegistration.Dynamic push = getServletContext().addFilter("push", PushCacheFilter.class);
push.setInitParameters(new HashMap<String, String>() {{
put("maxAssociations", "" + 32);
put("ports", "" + SSL_PORT);
}});
}},
new ServletContextHandler() {{
addServlet(AdapterServlet.class, "/*");
}}
));
}});
}});
}});
}
};
}
public void start() throws Exception {
server.start();
}
@Override
public void close() throws Exception {
server.stop();
}
public static void main(String... args) throws Exception {
AppKt.hz = Hazelcast.getOrCreateHazelcastInstance(new Config(args.length > 1 ? args[1] : "default"));
JettyJavaStarter it = new JettyJavaStarter(args);
it.start();
synchronized (it) {
it.wait();
}
}
}

On Sun, Feb 17, 2019 at 1:28 PM James Northrup <[hidden email]> wrote:

at id.kbr.prime.JettyJavaStarter.main(JettyJavaStarter.java:111)
Suppressed: java.lang.NullPointerException
at org.eclipse.jetty.servlets.PushCacheFilter.init(PushCacheFilter.java:114)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)


again, whatever I'm doing is just uninformed guesswork from incomplete knowledge.  the reason for various features is to support 100/100 lighthouse score on hnpwa or thereabouts.

roughly speaking, jetty should be able to host e.g. https://github.com/dsolimando/hnpwa-mobileelements  with http2-push as designed.  adding an additional rest-api is the tweak you need to be able to drive the static content with java backend frameworks .





On Sun, Feb 17, 2019 at 11:54 AM James Northrup <[hidden email]> wrote:

On Fri, Feb 15, 2019 at 2:59 PM Simone Bordet <[hidden email]> wrote:
Hi,


On Fri, Feb 15, 2019 at 6:29 AM James Northrup <[hidden email]> wrote:
>
> revising the servletcontextholder changes the result:   https://gist.github.com/jnorthrup/792a43d73178ee38d686035fca3d146d

It NPEs at PushCacheFilter.java:114, which is:

config.getServletContext().setAttribute(config.getFilterName(), this);

A NPE there is not possible, unless "config" is null, or the
ServletContext is null.
In both cases it is a major break of the implementation of the Servlet
specification, which I doubt it's the case (we would have a million
reports by now).

Have you tried to _not_ use coroutines, at least to initialize Jetty?

I would recommend that you start with the simplest possible Jetty
server configuration: a server, one connector, one
ServletContextHandler.
Try that and see if it works. Then start adding things until it breaks.

Since it's Kotlin, try also to write it in pure Java first and then
convert to Kotlin.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Simone Bordet-3
Hi,

On Tue, Feb 19, 2019 at 7:20 AM James Northrup <[hidden email]> wrote:
> SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, alpnConnectionFactory.getProtocol());
> ServerConnector httpsConnector = new ServerConnector(server, sslConnectionFactory, alpnConnectionFactory,http2ConnectionFactory, httpConnectionFactory);
> httpsConnector.setPort(SSL_PORT);
>
> becomes:
>
> https://gist.github.com/jnorthrup/1ee1974e45ae387663e9f49843b05cf6
>
> (launcher code included below the log)

The logs show:

13:10:01.038 [qtp341878976-48] DEBUG
org.eclipse.jetty.server.HttpConnection -
HttpConnection@695185eb::SocketChannelEndPoint@17937937{/127.0.0.1:54802<->/127.0.0.1:8080,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=1}...
13:10:01.039 [qtp341878976-27] DEBUG org.eclipse.jetty.http.HttpParser
- Illegal character CNTL=0x16 in state=START for buffer
HeapByteBuffer@46c545dc[p=1,l=517,c=8192,r=516]={\x16<<<\x03\x01\x02\x00\x01\x00\x01\xFc\x03\x03\xA0\x1a\x13\xE9\xC0\x12\xD8...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>>>

The buffer contains a 0x16 0x03 sequence which is the start of a TLS
record, and you have sent the encrypted request to port 8080 (shown in
the first line).

You have sent an https request to the http port.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
 yes, I was aware of that, but at no point did i specify https to 8080.  i specified https://0.0.0.0:8443 and got the result shown.  

without specifying httpsConnector.setPort(SSL_PORT) there simply was no connection on 8443 to the ephemeral port Jetty had chosen

i will repeat the test with the code, given the possibility that my chrome history jumped in from last week and forced itself on me, including nuke the service workers, and report back.   

On Tue, Feb 19, 2019 at 7:06 PM Simone Bordet <[hidden email]> wrote:
Hi,

On Tue, Feb 19, 2019 at 7:20 AM James Northrup <[hidden email]> wrote:
> SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, alpnConnectionFactory.getProtocol());
> ServerConnector httpsConnector = new ServerConnector(server, sslConnectionFactory, alpnConnectionFactory,http2ConnectionFactory, httpConnectionFactory);
> httpsConnector.setPort(SSL_PORT);
>
> becomes:
>
> https://gist.github.com/jnorthrup/1ee1974e45ae387663e9f49843b05cf6
>
> (launcher code included below the log)

The logs show:

13:10:01.038 [qtp341878976-48] DEBUG
org.eclipse.jetty.server.HttpConnection -
HttpConnection@695185eb::SocketChannelEndPoint@17937937{/127.0.0.1:54802<->/127.0.0.1:8080,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=1}...
13:10:01.039 [qtp341878976-27] DEBUG org.eclipse.jetty.http.HttpParser
- Illegal character CNTL=0x16 in state=START for buffer
HeapByteBuffer@46c545dc[p=1,l=517,c=8192,r=516]={\x16<<<\x03\x01\x02\x00\x01\x00\x01\xFc\x03\x03\xA0\x1a\x13\xE9\xC0\x12\xD8...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>>>

The buffer contains a 0x16 0x03 sequence which is the start of a TLS
record, and you have sent the encrypted request to port 8080 (shown in
the first line).

You have sent an https request to the http port.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
btw, what would it take to follow along with the google PWA tutorial golang http2 server and recorgnize byte 0x16 is missing and kick a 302 out? 

as it stands, it looks like i have to run two completely unrelated jetty servers, one with a hardcoded 302 servlet on http and the http2 i'm chasing down now.

 

On Tue, Feb 19, 2019 at 7:14 PM James Northrup <[hidden email]> wrote:
 yes, I was aware of that, but at no point did i specify https to 8080.  i specified https://0.0.0.0:8443 and got the result shown.  

without specifying httpsConnector.setPort(SSL_PORT) there simply was no connection on 8443 to the ephemeral port Jetty had chosen

i will repeat the test with the code, given the possibility that my chrome history jumped in from last week and forced itself on me, including nuke the service workers, and report back.   

On Tue, Feb 19, 2019 at 7:06 PM Simone Bordet <[hidden email]> wrote:
Hi,

On Tue, Feb 19, 2019 at 7:20 AM James Northrup <[hidden email]> wrote:
> SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, alpnConnectionFactory.getProtocol());
> ServerConnector httpsConnector = new ServerConnector(server, sslConnectionFactory, alpnConnectionFactory,http2ConnectionFactory, httpConnectionFactory);
> httpsConnector.setPort(SSL_PORT);
>
> becomes:
>
> https://gist.github.com/jnorthrup/1ee1974e45ae387663e9f49843b05cf6
>
> (launcher code included below the log)

The logs show:

13:10:01.038 [qtp341878976-48] DEBUG
org.eclipse.jetty.server.HttpConnection -
HttpConnection@695185eb::SocketChannelEndPoint@17937937{/127.0.0.1:54802<->/127.0.0.1:8080,OPEN,fill=-,flush=-,to=0/30000}{io=0/0,kio=0,kro=1}...
13:10:01.039 [qtp341878976-27] DEBUG org.eclipse.jetty.http.HttpParser
- Illegal character CNTL=0x16 in state=START for buffer
HeapByteBuffer@46c545dc[p=1,l=517,c=8192,r=516]={\x16<<<\x03\x01\x02\x00\x01\x00\x01\xFc\x03\x03\xA0\x1a\x13\xE9\xC0\x12\xD8...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>>>

The buffer contains a 0x16 0x03 sequence which is the start of a TLS
record, and you have sent the encrypted request to port 8080 (shown in
the first line).

You have sent an https request to the http port.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Simone Bordet-3
Hi,
On Tue, Feb 19, 2019 at 1:18 PM James Northrup <[hidden email]> wrote:
>
> btw, what would it take to follow along with the google PWA tutorial golang http2 server and recorgnize byte 0x16 is missing and kick a 302 out?

This feature is already available in Jetty 9.4.15.
You have to configure Jetty with OptionalSslConnectionFactory.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: EXTERNAL: Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Daly, Jeff
UNSUBSCRIBE

-----Original Message-----
From: [hidden email] <[hidden email]> On Behalf Of Simone Bordet
Sent: Tuesday, February 19, 2019 7:39 AM
To: JETTY user mailing list <[hidden email]>
Subject: EXTERNAL: Re: [jetty-users] embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Hi,
On Tue, Feb 19, 2019 at 1:18 PM James Northrup <[hidden email]> wrote:
>
> btw, what would it take to follow along with the google PWA tutorial golang http2 server and recorgnize byte 0x16 is missing and kick a 302 out?

This feature is already available in Jetty 9.4.15.
You have to configure Jetty with OptionalSslConnectionFactory.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
In reply to this post by Simone Bordet-3
Simone, Joakim, would it be possible to see all of these combined layered features as quoted above in a pre-tested code snippet?   

the goal I have for http2 on port 8443 with a port 8080 302 response forwarding to 8443, providing welcome files, gzip, static, h2 push, and a rest-api to intercept missing content seems close, but still subject to whack-a-mole 

after a couple weeks of using what i had before this thread, i sat back down and repeated my unsuccessful climb, similar to whatever gists are posted prior..

TIA



On Tue, Feb 19, 2019 at 7:39 PM Simone Bordet <[hidden email]> wrote:
Hi,
On Tue, Feb 19, 2019 at 1:18 PM James Northrup <[hidden email]> wrote:
>
> btw, what would it take to follow along with the google PWA tutorial golang http2 server and recorgnize byte 0x16 is missing and kick a 302 out?

This feature is already available in Jetty 9.4.15.
You have to configure Jetty with OptionalSslConnectionFactory.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

Joakim Erdfelt-8
The "and a rest-api to intercept missing content" is ambiguous.

It could be as easy as setting up an ErrorHandler on 404 to a specific rest API endpoint.
Thing is, if you do that, your rest API can never respond 404 unless it's DispatcherType.ERROR aware (which few rest APIs are)

Joakim Erdfelt / [hidden email]


On Sat, Mar 9, 2019 at 10:02 AM James Northrup <[hidden email]> wrote:
Simone, Joakim, would it be possible to see all of these combined layered features as quoted above in a pre-tested code snippet?   

the goal I have for http2 on port 8443 with a port 8080 302 response forwarding to 8443, providing welcome files, gzip, static, h2 push, and a rest-api to intercept missing content seems close, but still subject to whack-a-mole 

after a couple weeks of using what i had before this thread, i sat back down and repeated my unsuccessful climb, similar to whatever gists are posted prior..

TIA



On Tue, Feb 19, 2019 at 7:39 PM Simone Bordet <[hidden email]> wrote:
Hi,
On Tue, Feb 19, 2019 at 1:18 PM James Northrup <[hidden email]> wrote:
>
> btw, what would it take to follow along with the google PWA tutorial golang http2 server and recorgnize byte 0x16 is missing and kick a 302 out?

This feature is already available in Jetty 9.4.15.
You have to configure Jetty with OptionalSslConnectionFactory.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: embedded welcomefiles+http2-push+gzip-static-content+rest-api configuration

James Northrup
deeper rtfm leads me to beleive I should refactor to a handler, yes, though i want the handler's results to have h2 push and gzip as well 

On Thu, Mar 14, 2019 at 5:10 AM Joakim Erdfelt <[hidden email]> wrote:
The "and a rest-api to intercept missing content" is ambiguous.

It could be as easy as setting up an ErrorHandler on 404 to a specific rest API endpoint.
Thing is, if you do that, your rest API can never respond 404 unless it's DispatcherType.ERROR aware (which few rest APIs are)

Joakim Erdfelt / [hidden email]


On Sat, Mar 9, 2019 at 10:02 AM James Northrup <[hidden email]> wrote:
Simone, Joakim, would it be possible to see all of these combined layered features as quoted above in a pre-tested code snippet?   

the goal I have for http2 on port 8443 with a port 8080 302 response forwarding to 8443, providing welcome files, gzip, static, h2 push, and a rest-api to intercept missing content seems close, but still subject to whack-a-mole 

after a couple weeks of using what i had before this thread, i sat back down and repeated my unsuccessful climb, similar to whatever gists are posted prior..

TIA



On Tue, Feb 19, 2019 at 7:39 PM Simone Bordet <[hidden email]> wrote:
Hi,
On Tue, Feb 19, 2019 at 1:18 PM James Northrup <[hidden email]> wrote:
>
> btw, what would it take to follow along with the google PWA tutorial golang http2 server and recorgnize byte 0x16 is missing and kick a 302 out?

This feature is already available in Jetty 9.4.15.
You have to configure Jetty with OptionalSslConnectionFactory.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
12