I am using a single thread application to connect my client server Architecture. Basically this application will create many connections & close it automatically once the job is completed. We are getting an exception
'com.sshtools.j2ssh.transport.TransportProtocolException: The connection did not complete'
We have enabled j2ssh logs to figure out the root cause of the issue. Below are the complete details about the issue.
Java Version : jdk1.6.0_11
API Used : J2SSH Core 0.2.9 (j2ssh-core-0.2.9.jar)
com.sshtools.j2ssh.transport.TransportProtocolException: The connection did not complete
at com.sshtools.j2ssh.transport.TransportProtocolClient.onStartTransportProtocol(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.startTransportProtocol(Unknown Source)
at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
at info.itserv.globalinterface.gui.SFTP.openSSH(SFTP.java:95)
at info.itserv.globalinterface.gui.SFTP.connectionSFTP(SFTP.java:228)
........ and the following code
public void openSSH(String hostname, int authCode) {
try {
sshClient.connect(hostname,
new IgnoreHostKeyVerification());
sshClient.getConnectionProperties().setPort(this.port);
//Authenticate
GENERAL.println("Processing logging...");
switch (authCode) {
case 0:
this.login(this.username, this.password);
System.out.println("Password authentication");
break;
case 1:
//String keyFilename = "D:\\Cygwin\\home\\gtantot\\id_dsa";
this.loginCertificat(this.username, this.keyFilename,
this.passphrase);
System.out.println("Password authentication");
break;
default:
System.out.println("ECHEC SSH connection");
break;
}
this.sftp = sshClient.openSftpClient();
} catch (TransportProtocolException e) {
System.out.println("Transport: "+e.getMessage().toString() );
e.printStackTrace();
}
catch (IOException e1) {
System.out.println("Error openSSH: "+e1.getMessage());
e1.printStackTrace();
} }
public void closeSSH() {
if (sshClient != null) {
sshClient.disconnect();
}
}
Is there any way to overcome this error? As this kind of error will cause one sftp session of the application to be failed, what is the solution for this?