tail-f-systems / JNC

JNC (Java NETCONF Client) is the name of a Java library for communicating with NETCONF agents, and a plugin for pyang (http://code.google.com/p/pyang/) to generate Java classes from YANG models, to be used by the JNC library.
Other
77 stars 87 forks source link

Getting "Key exchange was not finished, connection is closed" exception #140

Open bndeshpande opened 1 year ago

bndeshpande commented 1 year ago

Hi Team, Recently upgraded our application from Java 8 to Java 17. And we have compiled the JNC and ganymed module as well. But when will bringup our springboot application will call device connect but we are seeing below exception:

This was not there when application running in Java8. Can any one help on this.

[main] Key exchange was not finished, connection is closed. java.io.IOException: Key exchange was not finished, connection is closed. at ch.ethz.ssh2.transport.KexManager.getOrWaitForConnectionInfo(KexManager.java:75) ~[ganymed-ssh2-262.jar!/:262] at ch.ethz.ssh2.transport.TransportManager.getConnectionInfo(TransportManager.java:169) ~[ganymed-ssh2-262.jar!/:262] at ch.ethz.ssh2.Connection.connect(Connection.java:759) ~[ganymed-ssh2-262.jar!/:262] at com.tailf.jnc.SSHConnection.(Unknown Source) ~[jnc-1.0.jar!/:?] at com.tailf.jnc.Device.connect(Unknown Source) ~[jnc-1.0.jar!/:?] at com.tailf.jnc.Device.connect(Unknown Source) ~[jnc-1.0.jar!/:?]

martin-volf commented 1 year ago

I'm not sure we can help you, this is an old version of the JNC client, the Ganymed SSH library is unsupported, again, can you migrate to a newer version?

bndeshpande commented 1 year ago

Thanks for info. We are using maven project so please check below new JNC gradle info converted to pom.xml to support maven based. Is this file is fine or anything needs to be added?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.tailf</groupId>
  <artifactId>jnc</artifactId>
  <version>1.2</version>
  <packaging>jar</packaging>

  <name>JNC</name>
  <description>JNC (Java NETCONF Client) is the name of a Java library for communicating with NETCONF agents. This version includes Mavenir changes for supporting NETCONF call home - RFC 8051. Also sets soTimeout for Device connections</description>
  <url>https://github.com/tail-f-systems/JNC</url>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://apache.org/licenses/LICENSE-2.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <organization>Tail-f Systems</organization>
      <organizationUrl>http://www.tail-f.com/</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git@github.com:tail-f-systems/JNC.git</connection>
    <developerConnection>scm:git:git@github.com:tail-f-systems/JNC.git</developerConnection>
    <url>git@github.com:tail-f-systems/JNC.git</url>
  </scm>

    <build>
        <!-- Specify maven non-standard source folder -->
        <sourceDirectory>src</sourceDirectory>      
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

  <dependencies>
    <dependency>
      <groupId>com.hierynomus</groupId>
      <artifactId>sshj</artifactId>
      <version>0.33.0</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.2.11</version>
    </dependency>
    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcprov-jdk15on</artifactId>
      <version>1.70</version>
    </dependency>
  </dependencies> 

</project>
martin-volf commented 1 year ago

This appears to be a POM file for building the JNC library, I would not expect you need that; I believe the "only" thing you need to do is to add a link to our Maven repository and JNC dependency declaration to your project's POM file.

martin-volf commented 1 year ago

For the sake of completeness, you need to have something like this in your POM (or POMs):

  <repositories>
    <repository>
      <id>jncrepo</id>
      <name>jnc github repo</name>
      <url>https://gitlab.com/api/v4/groups/57822468/-/packages/maven</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>com.tailf.jnc</groupId>
      <artifactId>JNC</artifactId>
      <version>1.1.0</version>
    </dependency>
  </dependencies>

That alone does not deal with generating Java classes from YANG modules using the pyang plugin, I assume you already have that somehow.