Skip to content

Commit

Permalink
Merge pull request #156 from rwth-acis/hotfix/http2
Browse files Browse the repository at this point in the history
http2 addon
  • Loading branch information
AlexanderNeumann authored Sep 15, 2022
2 parents d68be2e + 11c5496 commit e4749bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions webconnector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ dependencies {
implementation "org.webjars:swagger-ui:3.6.1"
implementation "javax.xml.bind:jaxb-api:2.3.1"
implementation "org.glassfish.jersey.inject:jersey-hk2:${project.property('jersey.version')}"
implementation "org.glassfish.grizzly:grizzly-http2:2.3.30"
implementation "org.glassfish.grizzly:grizzly-npn-api:1.8"
implementation "org.glassfish.grizzly:grizzly-npn-bootstrap:1.8.1"
}

// put all .jar files into export/jars folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.server.NetworkListener;
import org.glassfish.grizzly.http2.Http2AddOn;
import org.glassfish.grizzly.http2.Http2Configuration;
import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
import org.glassfish.grizzly.threadpool.ThreadPoolConfig;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
Expand Down Expand Up @@ -421,8 +423,17 @@ public void start(Node node) throws ConnectorException {

private void startHttpServer(ResourceConfig config) throws Exception {
http = GrizzlyHttpServerFactory.createHttpServer(new URI("http://0.0.0.0:"+ httpPort + "/"), config, false);

final TCPNIOTransport transport = http.getListener("grizzly").getTransport();
transport.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(maxThreads).setMaxPoolSize(maxThreads));

// Create default HTTP/2 configuration and provide it to the AddOn
Http2Configuration configuration = Http2Configuration.builder().build();
Http2AddOn http2Addon = new Http2AddOn(configuration);

// Register the Addon.
http.getListener("grizzly").registerAddOn(http2Addon);

http.start();
httpPort = http.getListener("grizzly").getPort();
logMessage("Web-Connector in HTTP mode running at " + getHttpEndpoint());
Expand Down

0 comments on commit e4749bf

Please sign in to comment.