in client/src/main/java/org/apache/ahc/AsyncHttpClient.java [686:721]
public void operationComplete(ConnectFuture future) {
if (future.isConnected()) {
notifyMonitoringListeners(MonitoringEvent.CONNECTION_SUCCESSFUL, request);
IoSession sess = future.getSession();
sess.getConfig().setReaderIdleTime(timeout);
// see if we need to add the SSL filter
addSSLFilter(sess);
// add the protocol filter (if it's not there already like in a
// reused session)
addProtocolCodecFilter(sess);
// (optional) add the executor filter for the event thread pool
// (if it's not there already like in a reused session)
addEventThreadPoolFilter(sess);
// now that we're connection, configure the session appropriately.
configureSession(sess);
// and finally start the request process rolling.
sess.write(request);
}
else {
if (retries-- > 0) {
// go retry this connection
retryConnection(request, response, this);
}
else {
try {
notifyMonitoringListeners(MonitoringEvent.CONNECTION_FAILED, request);
future.getSession();
response.setException(new AsyncHttpClientException("Connection failed."));
} catch (RuntimeIoException e) {
//Set the future exception
response.setException(e);
}
}
}
}