SPDY "Hello Server" with Jetty

I am trying to configure a minimal HTTP server with SPDY with Jetty for testing purposes. I am working on this code:

import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.spdy.http.HTTPSPDYServerConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; public class MySPDYHelloServer { public static void main(String[] args) throws Exception { Server server = new Server(); SslContextFactory sslFactory = new SslContextFactory(); sslFactory.setKeyStorePath("dummy_keystore.jks"); sslFactory.setKeyStorePassword("password"); sslFactory.setProtocol("TLSv1"); Connector connector = new HTTPSPDYServerConnector(sslFactory); connector.setPort(8443); server.addConnector(connector); server.setHandler( new AbstractHandler(){ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html;charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); baseRequest.setHandled(true); response.getWriter().println("<h1>Hello World</h1>"); } } ); server.start(); server.join(); } } 

I created a keystore:

 keytool -genkey -keystore dummy_keystore.jks 

When I point Google Chrome (with SPDY support) to https://localhost:8443 , it warns me of an untrusted certificate and then loads forever.

Examples of pure SPDY client servers (from here ) work and a simple HTTPS server works; The problem is with the HTTPSPDYServerConnector class.

Here is the list of JARs that I use:

 jetty-all-7.6.7.v20120910.jar npn-boot-7.6.2.v20120308.jar servlet-api-2.5.jar spdy-core-7.6.7.v20120910.jar spdy-jetty-7.6.7.v20120910.jar spdy-jetty-http-7.6.7.v20120910.jar 

And as for my Java environment:

 $ cat /opt/jdk1.7.0_07/release JAVA_VERSION="1.7.0" OS_NAME="Linux" OS_VERSION="2.6" OS_ARCH="i586" 

Appendix to the decision

jesse mcconnell provided the answer , anyway those using Eclipse might find the following useful.

JAR npn-boot-7.6.2.v20120308.jar should (also) be placed in:

 Run Configurations... -> Classpath -> Bootstrap Entries -> Add External JARs 

Note that since order matters , this entry should look up to the JRE System Library .

+7
source share
1 answer

Do you use npn-boot as a jar of bootclasspath at startup?

Stock jvm does not support npn (the following protocol negotiation), and spdy will not work, so you must make sure that the npn-boot jar is used in conjunction with the -Xbootclasspath option. This seems like your problem, since you are downloading certificates and then stopping it ... also that you refer to npn-boot as a dependency, when it is more likely to replace jvm classes than a typical dependency.

+6
source

All Articles