Using SPDY with Grizzly

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

Using SPDY with Grizzly

Steve Curtis

I’ve inherited a client-server application that creates a significant amount of asynchronous ajax calls from the front end.  We were using Simple Framework for our backend and I have now swapped in Grizzly with the intention of making use of SPDY protocol to avoid the max 6 browser connections we are seeing at the moment.

 

I have the application standing up fine, but it still seems to use standard HTTP 1.1 over SSL and not SPDY.

 

The code I’ve written is:

 

public void runServer(int port) throws IOException
{
logger.info("starting grizzly framework server on port {}", port);

ResourceConfig resourceConfig = new ResourceConfig(JerseyResource.class);
uri = UriBuilder.fromUri("https://localhost/").port(port).build();
server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator());

listener = server.getListeners().iterator().next();

listener.setSecure(true);
NIOTransport nioTransport = TCPNIOTransportBuilder.newInstance()
.setReuseAddress(true)
.setIOStrategy(WorkerThreadIOStrategy.getInstance())
.setSelectorThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(2).setMaxPoolSize(4))
.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(3).setMaxPoolSize(20))
.build();
listener.setTransport((TCPNIOTransport)nioTransport);

SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
listener.registerAddOn(spdyAddOn);

final ServerConfiguration serverConfiguration = server.getServerConfiguration();
serverConfiguration.addHttpHandler(new HttpHandler()
{
public void service(Request request, Response response) throws Exception
{
long startTime = new Date().getTime();

// Put a short sleep in here so can see if requests queue up from browser
Thread.currentThread().sleep(500);

// Get SPDY stream if it exists
final SpdyStream spdyStream = (SpdyStream) request.getAttribute(SpdyStream.SPDY_STREAM_ATTRIBUTE);
// if spdy stream is null it is not a SPDY based request
if (spdyStream != null)
{
logger.info("found a SPDY stream");
}
else
{
logger.info("no SPDY stream available");
}
final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
final String date = format.format(new Date(System.currentTimeMillis()));
response.setContentType("text/plain");
response.setContentLength(date.length());
response.getWriter().write(date);
logger.info("processed request in {} ms", new Date().getTime() - startTime);
}
}
);

server.start();

logger.info("bootstrap of grizzly framework server complete, running on {}", uri);
}

protected SSLEngineConfigurator createSSLContextConfigurator() throws MalformedURLException
{

SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator();
ClassLoader classLoader = getClass().getClassLoader();
sslContextConfigurator.setKeyStoreFile(classLoader.getResource("keystore.jks").getFile().toString());
sslContextConfigurator.setKeyStorePass("changeit");

sslContextConfigurator.validateConfiguration(true);

SSLEngineConfigurator result = new SSLEngineConfigurator(
sslContextConfigurator.createSSLContext(),
false,
false,
false);
result.setClientMode(false);
return result;

} 

 

The code is hosted on GitHub at https://github.com/stevocurtis/public-development/blob/master/subprojects/playpens/java-playpen/web/grizzly-framework-playpen/src/main/java/com/fenixinfotech/grizzly/framework/playpen/JerseyGrizzlyFrameworkServer.java

 

Notes:

 

1.       I’ve run this against both open jdk 7 and oracle jdk 7.

2.       I’ve tried bootstrapping with both the grizzly-npn-bootstrap-1.0.jar and grizzly-npn-bootstrap-1.2.jar files.

3.       You can see the dependencies in the pom but they are:

 

jersey-container-grizzly2-http 2.35

grizzly-http2 2.3.25

grizzly-http-server 2.3.25

grizzly-spdy 2.3.25

grizzly-npn-bootstrap 1.2

 

I’m wondering is there anything else I need to do to “trigger” initiation of a SPDY protocol?  Setting headers maybe.

 

Thanks in advance,

 

Steve

Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Ryan Lubke-2
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.

June 12, 2016 at 16:22

I’ve inherited a client-server application that creates a significant amount of asynchronous ajax calls from the front end.  We were using Simple Framework for our backend and I have now swapped in Grizzly with the intention of making use of SPDY protocol to avoid the max 6 browser connections we are seeing at the moment.

 

I have the application standing up fine, but it still seems to use standard HTTP 1.1 over SSL and not SPDY.

 

The code I’ve written is:

 

public void runServer(int port) throws IOException
{
logger.info("starting grizzly framework server on port {}", port);

ResourceConfig resourceConfig = new ResourceConfig(JerseyResource.class);
uri = UriBuilder.fromUri("https://localhost/").port(port).build();
server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator());

listener = server.getListeners().iterator().next();

listener.setSecure(true);
NIOTransport nioTransport = TCPNIOTransportBuilder.newInstance()
.setReuseAddress(true)
.setIOStrategy(WorkerThreadIOStrategy.getInstance())
.setSelectorThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(2).setMaxPoolSize(4))
.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(3).setMaxPoolSize(20))
.build();
listener.setTransport((TCPNIOTransport)nioTransport);

SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
listener.registerAddOn(spdyAddOn);

final ServerConfiguration serverConfiguration = server.getServerConfiguration();
serverConfiguration.addHttpHandler(new HttpHandler()
{
public void service(Request request, Response response) throws Exception
{
long startTime = new Date().getTime();

// Put a short sleep in here so can see if requests queue up from browser
Thread.currentThread().sleep(500);

// Get SPDY stream if it exists
final SpdyStream spdyStream = (SpdyStream) request.getAttribute(SpdyStream.SPDY_STREAM_ATTRIBUTE);
// if spdy stream is null it is not a SPDY based request
if (spdyStream != null)
{
logger.info("found a SPDY stream");
}
else
{
logger.info("no SPDY stream available");
}
final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
final String date = format.format(new Date(System.currentTimeMillis()));
response.setContentType("text/plain");
response.setContentLength(date.length());
response.getWriter().write(date);
logger.info("processed request in {} ms", new Date().getTime() - startTime);
}
}
);

server.start();

logger.info("bootstrap of grizzly framework server complete, running on {}", uri);
}

protected SSLEngineConfigurator createSSLContextConfigurator() throws MalformedURLException
{

SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator();
ClassLoader classLoader = getClass().getClassLoader();
sslContextConfigurator.setKeyStoreFile(classLoader.getResource("keystore.jks").getFile().toString());
sslContextConfigurator.setKeyStorePass("changeit");

sslContextConfigurator.validateConfiguration(true);

SSLEngineConfigurator result = new SSLEngineConfigurator(
sslContextConfigurator.createSSLContext(),
false,
false,
false);
result.setClientMode(false);
return result;

} 

 

The code is hosted on GitHub at https://github.com/stevocurtis/public-development/blob/master/subprojects/playpens/java-playpen/web/grizzly-framework-playpen/src/main/java/com/fenixinfotech/grizzly/framework/playpen/JerseyGrizzlyFrameworkServer.java

 

Notes:

 

1.       I’ve run this against both open jdk 7 and oracle jdk 7.

2.       I’ve tried bootstrapping with both the grizzly-npn-bootstrap-1.0.jar and grizzly-npn-bootstrap-1.2.jar files.

3.       You can see the dependencies in the pom but they are:

 

jersey-container-grizzly2-http 2.35

grizzly-http2 2.3.25

grizzly-http-server 2.3.25

grizzly-spdy 2.3.25

grizzly-npn-bootstrap 1.2

 

I’m wondering is there anything else I need to do to “trigger” initiation of a SPDY protocol?  Setting headers maybe.

 

Thanks in advance,

 

Steve


Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Steve Curtis
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers

On 13 June 2016 at 02:59, Ryan Lubke <[hidden email]> wrote:
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.

June 12, 2016 at 16:22

I’ve inherited a client-server application that creates a significant amount of asynchronous ajax calls from the front end.  We were using Simple Framework for our backend and I have now swapped in Grizzly with the intention of making use of SPDY protocol to avoid the max 6 browser connections we are seeing at the moment.

 

I have the application standing up fine, but it still seems to use standard HTTP 1.1 over SSL and not SPDY.

 

The code I’ve written is:

 

public void runServer(int port) throws IOException
{
logger.info("starting grizzly framework server on port {}", port);

ResourceConfig resourceConfig = new ResourceConfig(JerseyResource.class);
uri = UriBuilder.fromUri("https://localhost/").port(port).build();
server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator());

listener = server.getListeners().iterator().next();

listener.setSecure(true);
NIOTransport nioTransport = TCPNIOTransportBuilder.newInstance()
.setReuseAddress(true)
.setIOStrategy(WorkerThreadIOStrategy.getInstance())
.setSelectorThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(2).setMaxPoolSize(4))
.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(3).setMaxPoolSize(20))
.build();
listener.setTransport((TCPNIOTransport)nioTransport);

SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
listener.registerAddOn(spdyAddOn);

final ServerConfiguration serverConfiguration = server.getServerConfiguration();
serverConfiguration.addHttpHandler(new HttpHandler()
{
public void service(Request request, Response response) throws Exception
{
long startTime = new Date().getTime();

// Put a short sleep in here so can see if requests queue up from browser
Thread.currentThread().sleep(500);

// Get SPDY stream if it exists
final SpdyStream spdyStream = (SpdyStream) request.getAttribute(SpdyStream.SPDY_STREAM_ATTRIBUTE);
// if spdy stream is null it is not a SPDY based request
if (spdyStream != null)
{
logger.info("found a SPDY stream");
}
else
{
logger.info("no SPDY stream available");
}
final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
final String date = format.format(new Date(System.currentTimeMillis()));
response.setContentType("text/plain");
response.setContentLength(date.length());
response.getWriter().write(date);
logger.info("processed request in {} ms", new Date().getTime() - startTime);
}
}
);

server.start();

logger.info("bootstrap of grizzly framework server complete, running on {}", uri);
}

protected SSLEngineConfigurator createSSLContextConfigurator() throws MalformedURLException
{

SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator();
ClassLoader classLoader = getClass().getClassLoader();
sslContextConfigurator.setKeyStoreFile(classLoader.getResource("keystore.jks").getFile().toString());
sslContextConfigurator.setKeyStorePass("changeit");

sslContextConfigurator.validateConfiguration(true);

SSLEngineConfigurator result = new SSLEngineConfigurator(
sslContextConfigurator.createSSLContext(),
false,
false,
false);
result.setClientMode(false);
return result;

} 

 

The code is hosted on GitHub at https://github.com/stevocurtis/public-development/blob/master/subprojects/playpens/java-playpen/web/grizzly-framework-playpen/src/main/java/com/fenixinfotech/grizzly/framework/playpen/JerseyGrizzlyFrameworkServer.java

 

Notes:

 

1.       I’ve run this against both open jdk 7 and oracle jdk 7.

2.       I’ve tried bootstrapping with both the grizzly-npn-bootstrap-1.0.jar and grizzly-npn-bootstrap-1.2.jar files.

3.       You can see the dependencies in the pom but they are:

 

jersey-container-grizzly2-http 2.35

grizzly-http2 2.3.25

grizzly-http-server 2.3.25

grizzly-spdy 2.3.25

grizzly-npn-bootstrap 1.2

 

I’m wondering is there anything else I need to do to “trigger” initiation of a SPDY protocol?  Setting headers maybe.

 

Thanks in advance,

 

Steve



Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Steve Curtis
Just a quick update to say I updated the github code to remove the HttpHandler and build responses via the Jersey annotated resource class, the code should be simpler to follow.

Everything starts but I don't see SPDY protocol enabled (I'm using the Chrome "HTTP/2 and SPDY indicator" plugin to test this).

Is there anything extra I need to do from the client or server sides?  Maybe setting HTTP headers or something else to initiate the protocol?

Any help would be greatly appreciated.

Steve

On 13 June 2016 at 10:36, Steve Curtis <[hidden email]> wrote:
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers

On 13 June 2016 at 02:59, Ryan Lubke <[hidden email]> wrote:
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.

June 12, 2016 at 16:22

I’ve inherited a client-server application that creates a significant amount of asynchronous ajax calls from the front end.  We were using Simple Framework for our backend and I have now swapped in Grizzly with the intention of making use of SPDY protocol to avoid the max 6 browser connections we are seeing at the moment.

 

I have the application standing up fine, but it still seems to use standard HTTP 1.1 over SSL and not SPDY.

 

The code I’ve written is:

 

public void runServer(int port) throws IOException
{
logger.info("starting grizzly framework server on port {}", port);

ResourceConfig resourceConfig = new ResourceConfig(JerseyResource.class);
uri = UriBuilder.fromUri("https://localhost/").port(port).build();
server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator());

listener = server.getListeners().iterator().next();

listener.setSecure(true);
NIOTransport nioTransport = TCPNIOTransportBuilder.newInstance()
.setReuseAddress(true)
.setIOStrategy(WorkerThreadIOStrategy.getInstance())
.setSelectorThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(2).setMaxPoolSize(4))
.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(3).setMaxPoolSize(20))
.build();
listener.setTransport((TCPNIOTransport)nioTransport);

SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
listener.registerAddOn(spdyAddOn);

final ServerConfiguration serverConfiguration = server.getServerConfiguration();
serverConfiguration.addHttpHandler(new HttpHandler()
{
public void service(Request request, Response response) throws Exception
{
long startTime = new Date().getTime();

// Put a short sleep in here so can see if requests queue up from browser
Thread.currentThread().sleep(500);

// Get SPDY stream if it exists
final SpdyStream spdyStream = (SpdyStream) request.getAttribute(SpdyStream.SPDY_STREAM_ATTRIBUTE);
// if spdy stream is null it is not a SPDY based request
if (spdyStream != null)
{
logger.info("found a SPDY stream");
}
else
{
logger.info("no SPDY stream available");
}
final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
final String date = format.format(new Date(System.currentTimeMillis()));
response.setContentType("text/plain");
response.setContentLength(date.length());
response.getWriter().write(date);
logger.info("processed request in {} ms", new Date().getTime() - startTime);
}
}
);

server.start();

logger.info("bootstrap of grizzly framework server complete, running on {}", uri);
}

protected SSLEngineConfigurator createSSLContextConfigurator() throws MalformedURLException
{

SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator();
ClassLoader classLoader = getClass().getClassLoader();
sslContextConfigurator.setKeyStoreFile(classLoader.getResource("keystore.jks").getFile().toString());
sslContextConfigurator.setKeyStorePass("changeit");

sslContextConfigurator.validateConfiguration(true);

SSLEngineConfigurator result = new SSLEngineConfigurator(
sslContextConfigurator.createSSLContext(),
false,
false,
false);
result.setClientMode(false);
return result;

} 

 

The code is hosted on GitHub at https://github.com/stevocurtis/public-development/blob/master/subprojects/playpens/java-playpen/web/grizzly-framework-playpen/src/main/java/com/fenixinfotech/grizzly/framework/playpen/JerseyGrizzlyFrameworkServer.java

 

Notes:

 

1.       I’ve run this against both open jdk 7 and oracle jdk 7.

2.       I’ve tried bootstrapping with both the grizzly-npn-bootstrap-1.0.jar and grizzly-npn-bootstrap-1.2.jar files.

3.       You can see the dependencies in the pom but they are:

 

jersey-container-grizzly2-http 2.35

grizzly-http2 2.3.25

grizzly-http-server 2.3.25

grizzly-spdy 2.3.25

grizzly-npn-bootstrap 1.2

 

I’m wondering is there anything else I need to do to “trigger” initiation of a SPDY protocol?  Setting headers maybe.

 

Thanks in advance,

 

Steve




Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Ryan Lubke-2
Hi Steve,

You're next on my list.  Will follow up asap.

June 15, 2016 at 09:12
Just a quick update to say I updated the github code to remove the HttpHandler and build responses via the Jersey annotated resource class, the code should be simpler to follow.

Everything starts but I don't see SPDY protocol enabled (I'm using the Chrome "HTTP/2 and SPDY indicator" plugin to test this).

Is there anything extra I need to do from the client or server sides?  Maybe setting HTTP headers or something else to initiate the protocol?

Any help would be greatly appreciated.

Steve


June 13, 2016 at 02:36
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers


June 12, 2016 at 18:59
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.


June 12, 2016 at 16:22

I’ve inherited a client-server application that creates a significant amount of asynchronous ajax calls from the front end.  We were using Simple Framework for our backend and I have now swapped in Grizzly with the intention of making use of SPDY protocol to avoid the max 6 browser connections we are seeing at the moment.

 

I have the application standing up fine, but it still seems to use standard HTTP 1.1 over SSL and not SPDY.

 

The code I’ve written is:

 

public void runServer(int port) throws IOException
{
logger.info("starting grizzly framework server on port {}", port);

ResourceConfig resourceConfig = new ResourceConfig(JerseyResource.class);
uri = UriBuilder.fromUri("https://localhost/").port(port).build();
server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator());

listener = server.getListeners().iterator().next();

listener.setSecure(true);
NIOTransport nioTransport = TCPNIOTransportBuilder.newInstance()
.setReuseAddress(true)
.setIOStrategy(WorkerThreadIOStrategy.getInstance())
.setSelectorThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(2).setMaxPoolSize(4))
.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(3).setMaxPoolSize(20))
.build();
listener.setTransport((TCPNIOTransport)nioTransport);

SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
listener.registerAddOn(spdyAddOn);

final ServerConfiguration serverConfiguration = server.getServerConfiguration();
serverConfiguration.addHttpHandler(new HttpHandler()
{
public void service(Request request, Response response) throws Exception
{
long startTime = new Date().getTime();

// Put a short sleep in here so can see if requests queue up from browser
Thread.currentThread().sleep(500);

// Get SPDY stream if it exists
final SpdyStream spdyStream = (SpdyStream) request.getAttribute(SpdyStream.SPDY_STREAM_ATTRIBUTE);
// if spdy stream is null it is not a SPDY based request
if (spdyStream != null)
{
logger.info("found a SPDY stream");
}
else
{
logger.info("no SPDY stream available");
}
final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
final String date = format.format(new Date(System.currentTimeMillis()));
response.setContentType("text/plain");
response.setContentLength(date.length());
response.getWriter().write(date);
logger.info("processed request in {} ms", new Date().getTime() - startTime);
}
}
);

server.start();

logger.info("bootstrap of grizzly framework server complete, running on {}", uri);
}

protected SSLEngineConfigurator createSSLContextConfigurator() throws MalformedURLException
{

SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator();
ClassLoader classLoader = getClass().getClassLoader();
sslContextConfigurator.setKeyStoreFile(classLoader.getResource("keystore.jks").getFile().toString());
sslContextConfigurator.setKeyStorePass("changeit");

sslContextConfigurator.validateConfiguration(true);

SSLEngineConfigurator result = new SSLEngineConfigurator(
sslContextConfigurator.createSSLContext(),
false,
false,
false);
result.setClientMode(false);
return result;

} 

 

The code is hosted on GitHub at https://github.com/stevocurtis/public-development/blob/master/subprojects/playpens/java-playpen/web/grizzly-framework-playpen/src/main/java/com/fenixinfotech/grizzly/framework/playpen/JerseyGrizzlyFrameworkServer.java

 

Notes:

 

1.       I’ve run this against both open jdk 7 and oracle jdk 7.

2.       I’ve tried bootstrapping with both the grizzly-npn-bootstrap-1.0.jar and grizzly-npn-bootstrap-1.2.jar files.

3.       You can see the dependencies in the pom but they are:

 

jersey-container-grizzly2-http 2.35

grizzly-http2 2.3.25

grizzly-http-server 2.3.25

grizzly-spdy 2.3.25

grizzly-npn-bootstrap 1.2

 

I’m wondering is there anything else I need to do to “trigger” initiation of a SPDY protocol?  Setting headers maybe.

 

Thanks in advance,

 

Steve


Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Steve Curtis
Thanks Ryan - appreciate it.

I've tried to make it as easy as possible to replicate, the github project is simple maven build and you can run the server up either via JerseyGrizzlyFrameworkServer (has a main method) or the JerseyGrizzlyFrameworkServerTest unit test.

I'm convinced it is something very obvious I've missed :-)

Cheers

On 15 June 2016 at 17:38, Ryan Lubke <[hidden email]> wrote:
Hi Steve,

You're next on my list.  Will follow up asap.

June 15, 2016 at 09:12
Just a quick update to say I updated the github code to remove the HttpHandler and build responses via the Jersey annotated resource class, the code should be simpler to follow.

Everything starts but I don't see SPDY protocol enabled (I'm using the Chrome "HTTP/2 and SPDY indicator" plugin to test this).

Is there anything extra I need to do from the client or server sides?  Maybe setting HTTP headers or something else to initiate the protocol?

Any help would be greatly appreciated.

Steve


June 13, 2016 at 02:36
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers


June 12, 2016 at 18:59
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.


June 12, 2016 at 16:22

I’ve inherited a client-server application that creates a significant amount of asynchronous ajax calls from the front end.  We were using Simple Framework for our backend and I have now swapped in Grizzly with the intention of making use of SPDY protocol to avoid the max 6 browser connections we are seeing at the moment.

 

I have the application standing up fine, but it still seems to use standard HTTP 1.1 over SSL and not SPDY.

 

The code I’ve written is:

 

public void runServer(int port) throws IOException
{
logger.info("starting grizzly framework server on port {}", port);

ResourceConfig resourceConfig = new ResourceConfig(JerseyResource.class);
uri = UriBuilder.fromUri("https://localhost/").port(port).build();
server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator());

listener = server.getListeners().iterator().next();

listener.setSecure(true);
NIOTransport nioTransport = TCPNIOTransportBuilder.newInstance()
.setReuseAddress(true)
.setIOStrategy(WorkerThreadIOStrategy.getInstance())
.setSelectorThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(2).setMaxPoolSize(4))
.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(3).setMaxPoolSize(20))
.build();
listener.setTransport((TCPNIOTransport)nioTransport);

SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
listener.registerAddOn(spdyAddOn);

final ServerConfiguration serverConfiguration = server.getServerConfiguration();
serverConfiguration.addHttpHandler(new HttpHandler()
{
public void service(Request request, Response response) throws Exception
{
long startTime = new Date().getTime();

// Put a short sleep in here so can see if requests queue up from browser
Thread.currentThread().sleep(500);

// Get SPDY stream if it exists
final SpdyStream spdyStream = (SpdyStream) request.getAttribute(SpdyStream.SPDY_STREAM_ATTRIBUTE);
// if spdy stream is null it is not a SPDY based request
if (spdyStream != null)
{
logger.info("found a SPDY stream");
}
else
{
logger.info("no SPDY stream available");
}
final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
final String date = format.format(new Date(System.currentTimeMillis()));
response.setContentType("text/plain");
response.setContentLength(date.length());
response.getWriter().write(date);
logger.info("processed request in {} ms", new Date().getTime() - startTime);
}
}
);

server.start();

logger.info("bootstrap of grizzly framework server complete, running on {}", uri);
}

protected SSLEngineConfigurator createSSLContextConfigurator() throws MalformedURLException
{

SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator();
ClassLoader classLoader = getClass().getClassLoader();
sslContextConfigurator.setKeyStoreFile(classLoader.getResource("keystore.jks").getFile().toString());
sslContextConfigurator.setKeyStorePass("changeit");

sslContextConfigurator.validateConfiguration(true);

SSLEngineConfigurator result = new SSLEngineConfigurator(
sslContextConfigurator.createSSLContext(),
false,
false,
false);
result.setClientMode(false);
return result;

} 

 

The code is hosted on GitHub at https://github.com/stevocurtis/public-development/blob/master/subprojects/playpens/java-playpen/web/grizzly-framework-playpen/src/main/java/com/fenixinfotech/grizzly/framework/playpen/JerseyGrizzlyFrameworkServer.java

 

Notes:

 

1.       I’ve run this against both open jdk 7 and oracle jdk 7.

2.       I’ve tried bootstrapping with both the grizzly-npn-bootstrap-1.0.jar and grizzly-npn-bootstrap-1.2.jar files.

3.       You can see the dependencies in the pom but they are:

 

jersey-container-grizzly2-http 2.35

grizzly-http2 2.3.25

grizzly-http-server 2.3.25

grizzly-spdy 2.3.25

grizzly-npn-bootstrap 1.2

 

I’m wondering is there anything else I need to do to “trigger” initiation of a SPDY protocol?  Setting headers maybe.

 

Thanks in advance,

 

Steve



Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Ryan Lubke-2
Hi Steve,

Sorry for the delay.

There's a minor change in JerseyGrizzlyFrameworkServer that should get your further.  Line 48, change to:

   server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator(), false);

Note, JDK 1.7 probably won't work with our NPN implementation due to changes for SNI.  Grizzly NPN 1.2 was released for OpenJDK 1.8.0_25.
It most definitely won't work with the latest OpenJDK 1.8 release (1.8.0_92).  I've updated the NPN/ALPN implementation to work with this version and will be releasing later today. 

At any rate, let's see where the aforementioned code change gets you and go from there.

Thanks,
-rl

June 16, 2016 at 02:56
Thanks Ryan - appreciate it.

I've tried to make it as easy as possible to replicate, the github project is simple maven build and you can run the server up either via JerseyGrizzlyFrameworkServer (has a main method) or the JerseyGrizzlyFrameworkServerTest unit test.

I'm convinced it is something very obvious I've missed :-)

Cheers


June 15, 2016 at 09:38
Hi Steve,

You're next on my list.  Will follow up asap.


June 15, 2016 at 09:12
Just a quick update to say I updated the github code to remove the HttpHandler and build responses via the Jersey annotated resource class, the code should be simpler to follow.

Everything starts but I don't see SPDY protocol enabled (I'm using the Chrome "HTTP/2 and SPDY indicator" plugin to test this).

Is there anything extra I need to do from the client or server sides?  Maybe setting HTTP headers or something else to initiate the protocol?

Any help would be greatly appreciated.

Steve


June 13, 2016 at 02:36
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers


June 12, 2016 at 18:59
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.



Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Steve Curtis
Hi Ryan,

Thanks for the suggestions.  I made the code changes (see Travis CI https://travis-ci.org/stevocurtis/public-development/builds/142066549 for build output).

The code builds fine and I ran it up with Open JDK 8.0.92 but it still doesn't seem to be using the SPDY protocol, note I'm using FireFox HTTP/2 and SPDY indicator addon to test this.

Have you been able to run this up and test this locally?  Or is there an example SPDY enabled app I could use as a reference?

At this point I'm tempted to rule this out as not working and look at putting a HTTP2 enabled proxy in front of my appserver instead.

Steve

On 27 June 2016 at 22:34, Ryan Lubke <[hidden email]> wrote:
Hi Steve,

Sorry for the delay.

There's a minor change in JerseyGrizzlyFrameworkServer that should get your further.  Line 48, change to:

   server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator(), false);

Note, JDK 1.7 probably won't work with our NPN implementation due to changes for SNI.  Grizzly NPN 1.2 was released for OpenJDK 1.8.0_25.
It most definitely won't work with the latest OpenJDK 1.8 release (1.8.0_92).  I've updated the NPN/ALPN implementation to work with this version and will be releasing later today. 

At any rate, let's see where the aforementioned code change gets you and go from there.

Thanks,
-rl

June 16, 2016 at 02:56
Thanks Ryan - appreciate it.

I've tried to make it as easy as possible to replicate, the github project is simple maven build and you can run the server up either via JerseyGrizzlyFrameworkServer (has a main method) or the JerseyGrizzlyFrameworkServerTest unit test.

I'm convinced it is something very obvious I've missed :-)

Cheers


June 15, 2016 at 09:38
Hi Steve,

You're next on my list.  Will follow up asap.


June 15, 2016 at 09:12
Just a quick update to say I updated the github code to remove the HttpHandler and build responses via the Jersey annotated resource class, the code should be simpler to follow.

Everything starts but I don't see SPDY protocol enabled (I'm using the Chrome "HTTP/2 and SPDY indicator" plugin to test this).

Is there anything extra I need to do from the client or server sides?  Maybe setting HTTP headers or something else to initiate the protocol?

Any help would be greatly appreciated.

Steve


June 13, 2016 at 02:36
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers


June 12, 2016 at 18:59
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.




Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Ryan Lubke-2
Yes, I was able to.  Can you send me your SSL handshake log?

Sent from my iPhone

On Jul 4, 2016, at 03:21, Steve Curtis <[hidden email]> wrote:

Hi Ryan,

Thanks for the suggestions.  I made the code changes (see Travis CI https://travis-ci.org/stevocurtis/public-development/builds/142066549 for build output).

The code builds fine and I ran it up with Open JDK 8.0.92 but it still doesn't seem to be using the SPDY protocol, note I'm using FireFox HTTP/2 and SPDY indicator addon to test this.

Have you been able to run this up and test this locally?  Or is there an example SPDY enabled app I could use as a reference?

At this point I'm tempted to rule this out as not working and look at putting a HTTP2 enabled proxy in front of my appserver instead.

Steve

On 27 June 2016 at 22:34, Ryan Lubke <[hidden email]> wrote:
Hi Steve,

Sorry for the delay.

There's a minor change in JerseyGrizzlyFrameworkServer that should get your further.  Line 48, change to:

   server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator(), false);

Note, JDK 1.7 probably won't work with our NPN implementation due to changes for SNI.  Grizzly NPN 1.2 was released for OpenJDK 1.8.0_25.
It most definitely won't work with the latest OpenJDK 1.8 release (1.8.0_92).  I've updated the NPN/ALPN implementation to work with this version and will be releasing later today. 

At any rate, let's see where the aforementioned code change gets you and go from there.

Thanks,
-rl

June 16, 2016 at 02:56
Thanks Ryan - appreciate it.

I've tried to make it as easy as possible to replicate, the github project is simple maven build and you can run the server up either via JerseyGrizzlyFrameworkServer (has a main method) or the JerseyGrizzlyFrameworkServerTest unit test.

I'm convinced it is something very obvious I've missed :-)

Cheers


June 15, 2016 at 09:38
Hi Steve,

You're next on my list.  Will follow up asap.


June 15, 2016 at 09:12
Just a quick update to say I updated the github code to remove the HttpHandler and build responses via the Jersey annotated resource class, the code should be simpler to follow.

Everything starts but I don't see SPDY protocol enabled (I'm using the Chrome "HTTP/2 and SPDY indicator" plugin to test this).

Is there anything extra I need to do from the client or server sides?  Maybe setting HTTP headers or something else to initiate the protocol?

Any help would be greatly appreciated.

Steve


June 13, 2016 at 02:36
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers


June 12, 2016 at 18:59
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.




Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Steve Curtis
I've attached the output Ryan - hope this helps.

On 4 July 2016 at 19:51, Ryan Lubke <[hidden email]> wrote:
Yes, I was able to.  Can you send me your SSL handshake log?

Sent from my iPhone

On Jul 4, 2016, at 03:21, Steve Curtis <[hidden email]> wrote:

Hi Ryan,

Thanks for the suggestions.  I made the code changes (see Travis CI https://travis-ci.org/stevocurtis/public-development/builds/142066549 for build output).

The code builds fine and I ran it up with Open JDK 8.0.92 but it still doesn't seem to be using the SPDY protocol, note I'm using FireFox HTTP/2 and SPDY indicator addon to test this.

Have you been able to run this up and test this locally?  Or is there an example SPDY enabled app I could use as a reference?

At this point I'm tempted to rule this out as not working and look at putting a HTTP2 enabled proxy in front of my appserver instead.

Steve

On 27 June 2016 at 22:34, Ryan Lubke <[hidden email]> wrote:
Hi Steve,

Sorry for the delay.

There's a minor change in JerseyGrizzlyFrameworkServer that should get your further.  Line 48, change to:

   server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator(), false);

Note, JDK 1.7 probably won't work with our NPN implementation due to changes for SNI.  Grizzly NPN 1.2 was released for OpenJDK 1.8.0_25.
It most definitely won't work with the latest OpenJDK 1.8 release (1.8.0_92).  I've updated the NPN/ALPN implementation to work with this version and will be releasing later today. 

At any rate, let's see where the aforementioned code change gets you and go from there.

Thanks,
-rl

June 16, 2016 at 02:56
Thanks Ryan - appreciate it.

I've tried to make it as easy as possible to replicate, the github project is simple maven build and you can run the server up either via JerseyGrizzlyFrameworkServer (has a main method) or the JerseyGrizzlyFrameworkServerTest unit test.

I'm convinced it is something very obvious I've missed :-)

Cheers


June 15, 2016 at 09:38
Hi Steve,

You're next on my list.  Will follow up asap.


June 15, 2016 at 09:12
Just a quick update to say I updated the github code to remove the HttpHandler and build responses via the Jersey annotated resource class, the code should be simpler to follow.

Everything starts but I don't see SPDY protocol enabled (I'm using the Chrome "HTTP/2 and SPDY indicator" plugin to test this).

Is there anything extra I need to do from the client or server sides?  Maybe setting HTTP headers or something else to initiate the protocol?

Any help would be greatly appreciated.

Steve


June 13, 2016 at 02:36
Hi Ryan,

I was running it with Open JDK 1.7.0_101

Since it's a Windows machine I'm developing on I used the Azul provided OpenJDK build at http://www.azul.com/downloads/zulu/zulu-windows/

Cheers


June 12, 2016 at 18:59
Hi Steve,

Do you recall the exact version of the Open JDK you tested with?  The NPN code is pretty sensitive to the version of the runtime.  NOTE:  It won't work at all with the Oracle JDK.






ssl_output.txt (124K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Ryan Lubke-2
Okay, so I think the root of the issue is detailed in this blog post [1].

When I tested using Chromium on Ubuntu, NPN and SPDY were still supported and it worked.  But testing with Chrome (version 51), The client, over ALPN, only supports HTTP/1.1 and HTTP/2.

Grizzly's HTTP/2 support is still in development, and this information is a good reason to put more time into it.

[1] http://blog.chromium.org/2016/02/transitioning-from-spdy-to-http2.html

July 5, 2016 at 03:21
I've attached the output Ryan - hope this helps.


July 4, 2016 at 11:51
Yes, I was able to.  Can you send me your SSL handshake log?

Sent from my iPhone

On Jul 4, 2016, at 03:21, Steve Curtis <[hidden email]> wrote:

July 4, 2016 at 03:21
Hi Ryan,

Thanks for the suggestions.  I made the code changes (see Travis CI https://travis-ci.org/stevocurtis/public-development/builds/142066549 for build output).

The code builds fine and I ran it up with Open JDK 8.0.92 but it still doesn't seem to be using the SPDY protocol, note I'm using FireFox HTTP/2 and SPDY indicator addon to test this.

Have you been able to run this up and test this locally?  Or is there an example SPDY enabled app I could use as a reference?

At this point I'm tempted to rule this out as not working and look at putting a HTTP2 enabled proxy in front of my appserver instead.

Steve


June 27, 2016 at 14:34
Hi Steve,

Sorry for the delay.

There's a minor change in JerseyGrizzlyFrameworkServer that should get your further.  Line 48, change to:

   server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator(), false);

Note, JDK 1.7 probably won't work with our NPN implementation due to changes for SNI.  Grizzly NPN 1.2 was released for OpenJDK 1.8.0_25.
It most definitely won't work with the latest OpenJDK 1.8 release (1.8.0_92).  I've updated the NPN/ALPN implementation to work with this version and will be releasing later today. 

At any rate, let's see where the aforementioned code change gets you and go from there.

Thanks,
-rl


June 16, 2016 at 02:56
Thanks Ryan - appreciate it.

I've tried to make it as easy as possible to replicate, the github project is simple maven build and you can run the server up either via JerseyGrizzlyFrameworkServer (has a main method) or the JerseyGrizzlyFrameworkServerTest unit test.

I'm convinced it is something very obvious I've missed :-)

Cheers



Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Steve Curtis
I noticed that myself Ryan, and have been testing the development with FireFox using the "HTTP/2 and SPDY indicator" extension.

I guess you have no roadmap for HTTP2 support in Grizzly anytime soon?

Is there any chance you could repeat your test using FireFox?  I think I may end up going down the HTTP2 enabled proxy route here, but I'd like to finish this investigation regardless, since I'm still not clear why this would;t be working via FireFox/IE.

On 5 July 2016 at 19:55, Ryan Lubke <[hidden email]> wrote:
Okay, so I think the root of the issue is detailed in this blog post [1].

When I tested using Chromium on Ubuntu, NPN and SPDY were still supported and it worked.  But testing with Chrome (version 51), The client, over ALPN, only supports HTTP/1.1 and HTTP/2.

Grizzly's HTTP/2 support is still in development, and this information is a good reason to put more time into it.

[1] http://blog.chromium.org/2016/02/transitioning-from-spdy-to-http2.html

July 5, 2016 at 03:21
I've attached the output Ryan - hope this helps.


July 4, 2016 at 11:51
Yes, I was able to.  Can you send me your SSL handshake log?

Sent from my iPhone

On Jul 4, 2016, at 03:21, Steve Curtis <[hidden email]> wrote:

July 4, 2016 at 03:21
Hi Ryan,

Thanks for the suggestions.  I made the code changes (see Travis CI https://travis-ci.org/stevocurtis/public-development/builds/142066549 for build output).

The code builds fine and I ran it up with Open JDK 8.0.92 but it still doesn't seem to be using the SPDY protocol, note I'm using FireFox HTTP/2 and SPDY indicator addon to test this.

Have you been able to run this up and test this locally?  Or is there an example SPDY enabled app I could use as a reference?

At this point I'm tempted to rule this out as not working and look at putting a HTTP2 enabled proxy in front of my appserver instead.

Steve


June 27, 2016 at 14:34
Hi Steve,

Sorry for the delay.

There's a minor change in JerseyGrizzlyFrameworkServer that should get your further.  Line 48, change to:

   server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true, createSSLContextConfigurator(), false);

Note, JDK 1.7 probably won't work with our NPN implementation due to changes for SNI.  Grizzly NPN 1.2 was released for OpenJDK 1.8.0_25.
It most definitely won't work with the latest OpenJDK 1.8 release (1.8.0_92).  I've updated the NPN/ALPN implementation to work with this version and will be releasing later today. 

At any rate, let's see where the aforementioned code change gets you and go from there.

Thanks,
-rl


June 16, 2016 at 02:56
Thanks Ryan - appreciate it.

I've tried to make it as easy as possible to replicate, the github project is simple maven build and you can run the server up either via JerseyGrizzlyFrameworkServer (has a main method) or the JerseyGrizzlyFrameworkServerTest unit test.

I'm convinced it is something very obvious I've missed :-)

Cheers




Reply | Threaded
Open this post in threaded view
|

Re: Using SPDY with Grizzly

Ryan Lubke-2
I see Firefox using SPDY:

---------------------------------------
... no MAC keys used for this cipher
Client write key:
0000: 52 97 03 17 91 CF 7C 0A   55 2C A3 BB 02 06 DC E2  R.......U,......
Server write key:
0000: 96 4F F8 93 B1 6E 2F E9   A9 C0 D6 E6 8A 2C EB 43  .O...n/......,.C
Client write IV:
0000: 33 7D 19 F2                                        3...
Server write IV:
0000: 4F 04 BE E6                                        O...
Grizzly(2), READ: TLSv1.2 Change Cipher Spec, length = 1
Grizzly(2), READ: TLSv1.2 Handshake, length = 76
NPN selected protocol is: spdy/3.1
*** Finished
verify_data:  { 123, 10, 117, 156, 81, 42, 155, 178, 196, 193, 249, 17 }
***
Grizzly(2), WRITE: TLSv1.2 Change Cipher Spec, length = 1
*** Finished
verify_data:  { 168, 116, 13, 30, 179, 172, 120, 174, 66, 221, 18, 198 }
***
---------------------------------------

FF version: 43.0.4

As to HTTP/2, we plan to get back to work on HTTP/2 once I feel the current issue list is in a good place.  No ETA on when we expect to complete the work, but it will be asap.

July 6, 2016 at 05:36
I noticed that myself Ryan, and have been testing the development with FireFox using the "HTTP/2 and SPDY indicator" extension.

I guess you have no roadmap for HTTP2 support in Grizzly anytime soon?

Is there any chance you could repeat your test using FireFox?  I think I may end up going down the HTTP2 enabled proxy route here, but I'd like to finish this investigation regardless, since I'm still not clear why this would;t be working via FireFox/IE.


July 5, 2016 at 11:55
Okay, so I think the root of the issue is detailed in this blog post [1].

When I tested using Chromium on Ubuntu, NPN and SPDY were still supported and it worked.  But testing with Chrome (version 51), The client, over ALPN, only supports HTTP/1.1 and HTTP/2.

Grizzly's HTTP/2 support is still in development, and this information is a good reason to put more time into it.

[1] http://blog.chromium.org/2016/02/transitioning-from-spdy-to-http2.html


July 5, 2016 at 03:21
I've attached the output Ryan - hope this helps.


July 4, 2016 at 11:51
Yes, I was able to.  Can you send me your SSL handshake log?

Sent from my iPhone

On Jul 4, 2016, at 03:21, Steve Curtis <[hidden email]> wrote:

July 4, 2016 at 03:21
Hi Ryan,

Thanks for the suggestions.  I made the code changes (see Travis CI https://travis-ci.org/stevocurtis/public-development/builds/142066549 for build output).

The code builds fine and I ran it up with Open JDK 8.0.92 but it still doesn't seem to be using the SPDY protocol, note I'm using FireFox HTTP/2 and SPDY indicator addon to test this.

Have you been able to run this up and test this locally?  Or is there an example SPDY enabled app I could use as a reference?

At this point I'm tempted to rule this out as not working and look at putting a HTTP2 enabled proxy in front of my appserver instead.

Steve