public void start(String host, int port) throws Exception { Bootstrap b = new Bootstrap(); b.group(workerGroup); b.channel(NioSocketChannel.class); b.option(ChannelOption.SO_KEEPALIVE, true); b.remoteAddress(host, port); b.handler(initializer); // Start the client. channel = b.connect().syncUninterruptibly().channel(); System.out.println("Connected to [" + host + ':' + port + ']'); initializer.upgradeToHttp2IfNeeded(); }