Add workaround for SSH connection issue related to SSHD-1028
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / handler / ssh / client / NetconfSshClient.java
index d5d0d97aa955636191257b0ef4e8e792fbb1a9ae..b4f318ebd25e2785baf5c388a1bd89ba0ad41ba0 100644 (file)
@@ -8,8 +8,11 @@
 package org.opendaylight.netconf.nettyutil.handler.ssh.client;
 
 import com.google.common.annotations.Beta;
+import org.opendaylight.netconf.nettyutil.handler.ssh.sshd1028.NetconfNio2ServiceFactoryFactory;
 import org.opendaylight.netconf.shaded.sshd.client.SshClient;
 import org.opendaylight.netconf.shaded.sshd.common.Factory;
+import org.opendaylight.netconf.shaded.sshd.common.io.IoConnector;
+
 
 /**
  * An extension to {@link SshClient} which uses {@link NetconfSessionFactory} to create sessions (leading towards
@@ -18,9 +21,20 @@ import org.opendaylight.netconf.shaded.sshd.common.Factory;
 @Beta
 public class NetconfSshClient extends SshClient {
     public static final Factory<SshClient> DEFAULT_NETCONF_SSH_CLIENT_FACTORY = NetconfSshClient::new;
+    private final NetconfNio2ServiceFactoryFactory nio2ServiceFactoryFactory;
+
+    public NetconfSshClient() {
+        this.nio2ServiceFactoryFactory = new NetconfNio2ServiceFactoryFactory();
+    }
 
     @Override
     protected NetconfSessionFactory createSessionFactory() {
         return new NetconfSessionFactory(this);
     }
+
+    @Override
+    protected IoConnector createConnector() {
+        setIoServiceFactoryFactory(nio2ServiceFactoryFactory);
+        return getIoServiceFactory().createConnector(getSessionFactory());
+    }
 }