void connectAndSendHeaders(boolean reconnect, HttpTunnelAddress remoteAddress) {
this.remoteAddress = remoteAddress;
URI url = remoteAddress.getUri();
if (reconnect) {
DefaultChannelPipeline channelPipeline = new DefaultChannelPipeline();
channelPipeline.addLast("DelimiterBasedFrameDecoder", handler);
channelPipeline.addLast("servletHandler", servletHandler);
channel = clientSocketChannelFactory.newChannel(channelPipeline);
}
SocketAddress connectAddress = new InetSocketAddress(url.getHost(), url.getPort());
channel.connect(connectAddress);