@Override
public void run() {
try {
logger.debug("STARTING SERVER FOR HTTP ON PORT: " + port);
ChannelFuture channelFutureHTTP = 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("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