import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
+import io.netty.util.concurrent.FutureListener;
import java.io.IOException;
import java.net.SocketAddress;
import java.util.concurrent.TimeUnit;
c.getProperties().put(CoreModuleProperties.AUTH_TIMEOUT.getName(), "0");
c.getProperties().put(CoreModuleProperties.IDLE_TIMEOUT.getName(), "0");
c.getProperties().put(CoreModuleProperties.NIO2_READ_TIMEOUT.getName(), "0");
+ c.getProperties().put(CoreModuleProperties.TCP_NODELAY.getName(), true);
// TODO make configurable, or somehow reuse netty threadpool
c.setNioWorkers(SSH_DEFAULT_NIO_WORKERS);
private NettyAwareChannelSubsystem channel;
private ClientSession session;
private ChannelPromise connectPromise;
- private GenericFutureListener negotiationFutureListener;
+ private FutureListener<Object> negotiationFutureListener;
public AsyncSshHandler(final AuthenticationHandler authenticationHandler, final NetconfSshClient sshClient,
final Future<?> negotiationFuture) {
private synchronized void handleSshAuthenticated(final NettyAwareClientSession newSession,
final ChannelHandlerContext ctx) {
- try {
- LOG.debug("SSH session authenticated on channel: {}, server version: {}", ctx.channel(),
- newSession.getServerVersion());
+ LOG.debug("SSH session authenticated on channel: {}, server version: {}", ctx.channel(),
+ newSession.getServerVersion());
+ try {
channel = newSession.createSubsystemChannel(SUBSYSTEM, ctx);
channel.setStreaming(ClientChannel.Streaming.Async);
channel.open().addListener(future -> {
handleSshSetupFailure(ctx, future.getException());
}
});
-
-
} catch (final IOException e) {
handleSshSetupFailure(ctx, e);
}
@Override
public synchronized void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
final SocketAddress localAddress, final ChannelPromise promise) throws Exception {
- LOG.debug("SSH session connecting on channel {}. promise: {} ", ctx.channel(), connectPromise);
- this.connectPromise = promise;
+ LOG.debug("SSH session connecting on channel {}. promise: {}", ctx.channel(), promise);
+ connectPromise = requireNonNull(promise);
if (negotiationFuture != null) {
negotiationFutureListener = future -> {