Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Connecting to Jetty 9.3.8 http2 connector without ALPN

Hi Simone & lurkers,
just wanted to confirm back that it is indeed working.

This is the connector-code I am using:

@Override
public Connector build(Server server, MetricRegistry metrics, String
name, ThreadPool threadPool) {
  setSupportedProtocols(ImmutableList.of("TLSv1.2"));
  setSupportedCipherSuites(ImmutableList.of("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"));
  logSupportedParameters();
  final HttpConfiguration httpConfig = buildHttpConfiguration();
  final HTTP2ServerConnectionFactory http2 = new
HTTP2ServerConnectionFactory(httpConfig);
  final SslContextFactory sslContextFactory = buildSslContextFactory();
  server.addBean(sslContextFactory);
  final SslConnectionFactory sslConnectionFactory = new
SslConnectionFactory(sslContextFactory, H2);
  return buildConnector(server, new ScheduledExecutorScheduler(),
buildBufferPool(), name, threadPool,
      new Jetty93InstrumentedConnectionFactory(sslConnectionFactory,
metrics.timer(httpConnections())), http2);
}

which creates a http2 only server.

My current client code is netty:

final SslContext sslCtx =
SslContextBuilder.forClient().sslProvider(SslProvider.JDK)
    .trustManager(InsecureTrustManagerFactory.INSTANCE)
    .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
    .applicationProtocolConfig(ApplicationProtocolConfig.DISABLED).build();
bootstrap = new Bootstrap();
Bootstrap b = bootstrap.group(group).channel(NioSocketChannel.class);
b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000);
b.option(ChannelOption.SO_KEEPALIVE, true);
b.remoteAddress(host, port);
b.handler(new ChannelInitializer<Channel>() {
  @Override
  protected void initChannel(Channel ch) throws Exception {
    final Http2Connection connection = new DefaultHttp2Connection(false);
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    pipeline.addLast(new HttpToHttp2ConnectionHandlerBuilder()
        .frameListener(
            new DelegatingDecompressorFrameListener(connection, new
InboundHttp2ToHttpAdapterBuilder(connection)

.maxContentLength(Integer.MAX_VALUE).propagateSettings(true).build()))
        .connection(connection).build());
    pipeline.addLast(new ResponseHandler());
  }
});
bootstrap.connect();

next step is checking out the jetty client library.

Thanks for your support, and maybe the above snippets are useful for somebody.

Fabian


Back to the top