public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("logger", new LoggingHandler("TEST_SERVER"));
pipeline.addLast("codec", new HttpServerCodec());
pipeline.addLast("chunk-aggregator", new HttpObjectAggregator(10 * 1024 * 1024));
pipeline.addLast("handler", new TestServerHandler());
}
})
.bind(port).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
hasBoundToHTTPPort.set("CONNECTED");
} else {
hasBoundToHTTPPort.setException(future.cause());
}
}
});
logger.debug("STARTING SERVER FOR HTTPS ON PORT: " + securePort);
ChannelFuture channelFutureHTTPS = new ServerBootstrap()
.option(ChannelOption.SO_BACKLOG, 1024)
.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("raw logger", new LoggingHandler("RAW TEST_SERVER_SSL"));
SSLEngine engine = SSLFactory.getInstance().sslContext().createSSLEngine();
engine.setUseClientMode(false);
pipeline.addLast("ssl", new SslHandler(engine));
pipeline.addLast("logger", new LoggingHandler("TEST_SERVER_SSL"));
pipeline.addLast("codec", new HttpServerCodec());
pipeline.addLast("chunk-aggregator", new HttpObjectAggregator(10 * 1024 * 1024));
pipeline.addLast("handler", new TestServerHandler());
}
})
.bind(securePort).addListener(new ChannelFutureListener() {
@Override