private void reconnect ( final NextFilter nextFilter , final HttpProxyRequest request ) { LOGGER . debug ( "Reconnecting to proxy ..." ) ; final ProxyIoSession proxyIoSession = getProxyIoSession ( ) ; // Fires reconnection proxyIoSession . getConnector ( ) . connect ( new IoSessionInitializer < ConnectFuture > ( ) { public void initializeSession ( final IoSession session , ConnectFuture future ) { LOGGER . debug ( "Initializing new session: {}" , session ) ; session . setAttribute ( ProxyIoSession . PROXY_SESSION , proxyIoSession ) ; proxyIoSession . setSession ( session ) ; LOGGER . debug ( " setting up proxyIoSession: {}" , proxyIoSession ) ; future . addListener ( new IoFutureListener < ConnectFuture > ( ) { public void operationComplete ( ConnectFuture future ) { // Reconnection is done so we send the // request to the proxy proxyIoSession . setReconnectionNeeded ( false ) ; writeRequest0 ( nextFilter , request ) ; } } ) ; } } ) ; }
Method to reconnect to the proxy when it decides not to maintain the connection during handshake .