When using following constructor of NonBlockingConnection class:
public NonBlockingConnection(String hostname, int port, SSLContext sslContext, boolean sslOn) throws IOException {
this(new InetSocketAddress(hostname, port), true, Integer.MAX_VALUE, new HashMap<String, Object>(), sslContext, sslOn, null, getDefaultWorkerpool(), null);
}
It passes waitForConnection = true and infinite timeout somewhy to underlying layer.
And then it leads to using of sync connector in private consturtor:
// sync connect
if (waitForConnect && (connectTimeoutMillis > 0)) { /// <------ ENTER HERE
SyncIoConnectorCallback callback = new SyncIoConnectorCallback(remoteAddress, channel, sslContext, isSecured, connectTimeoutMillis);
connector.connectAsync(channel, remoteAddress, connectTimeoutMillis, callback);
callback.connect(); //// <------ Wait by 500ms until or interrupted.
// async connect
} else {
IIoConnectorCallback callback = new AsyncIoConnectorCallback(remoteAddress, channel, sslContext, isSecured, connectTimeoutMillis);
connector.connectAsync(channel, remoteAddress, connectTimeoutMillis, callback);
}
What is it wrong with this? Why are you waiting (block current thread) for connection to be acquired in non blocking connector class?