+ };
+ //complete connection promise with netconf negotiation future
+ negotiationFuture.addListener(negotiationFutureListener);
+ }
+
+ LOG.debug("Starting SSH to {} on channel: {}", remoteAddress, ctx.channel());
+ sshClient.connect(authenticationHandler.getUsername(), remoteAddress)
+ // FIXME: this is a blocking call, we should handle this with a concurrently-scheduled timeout. We do not
+ // have a Timer ready, so perhaps we should be using the event loop?
+ .verify(ctx.channel().config().getConnectTimeoutMillis(), TimeUnit.MILLISECONDS)
+ .addListener(future -> onConnectComplete(future, ctx));
+ }
+
+ private void onConnectComplete(final ConnectFuture future, final ChannelHandlerContext ctx) {
+ final var cause = future.getException();
+ if (cause != null) {
+ onOpenFailure(ctx, cause);
+ return;
+ }
+
+ final var clientSession = future.getSession();
+ LOG.trace("SSH session {} created on channel: {}", clientSession, ctx.channel());
+ verify(clientSession instanceof NettyAwareClientSession, "Unexpected session %s", clientSession);
+ onConnectComplete((NettyAwareClientSession) clientSession, ctx);