use of org.asynchttpclient.netty.SimpleChannelFutureListener in project async-http-client by AsyncHttpClient.
the class NettyChannelConnector method connect0.
private void connect0(Bootstrap bootstrap, final NettyConnectListener<?> connectListener, InetSocketAddress remoteAddress) {
//
bootstrap.connect(remoteAddress, localAddress).addListener(new SimpleChannelFutureListener() {
@Override
public void onSuccess(Channel channel) {
if (asyncHandlerExtensions != null) {
asyncHandlerExtensions.onTcpConnectSuccess(remoteAddress, channel);
}
connectListener.onSuccess(channel, remoteAddress);
}
@Override
public void onFailure(Channel channel, Throwable t) {
if (asyncHandlerExtensions != null)
asyncHandlerExtensions.onTcpConnectFailure(remoteAddress, t);
boolean retry = pickNextRemoteAddress();
if (retry)
NettyChannelConnector.this.connect(bootstrap, connectListener);
else
connectListener.onFailure(channel, t);
}
});
}
use of org.asynchttpclient.netty.SimpleChannelFutureListener in project async-http-client by AsyncHttpClient.
the class NettyChannelConnector method connect0.
private void connect0(Bootstrap bootstrap, final NettyConnectListener<?> connectListener, InetSocketAddress remoteAddress) {
bootstrap.connect(remoteAddress, localAddress).addListener(new SimpleChannelFutureListener() {
@Override
public void onSuccess(Channel channel) {
try {
asyncHandler.onTcpConnectSuccess(remoteAddress, channel);
} catch (Exception e) {
LOGGER.error("onTcpConnectSuccess crashed", e);
connectListener.onFailure(channel, e);
return;
}
connectListener.onSuccess(channel, remoteAddress);
}
@Override
public void onFailure(Channel channel, Throwable t) {
try {
asyncHandler.onTcpConnectFailure(remoteAddress, t);
} catch (Exception e) {
LOGGER.error("onTcpConnectFailure crashed", e);
connectListener.onFailure(channel, e);
return;
}
boolean retry = pickNextRemoteAddress();
if (retry) {
NettyChannelConnector.this.connect(bootstrap, connectListener);
} else {
connectListener.onFailure(channel, t);
}
}
});
}
Aggregations