シングル スレッド アプリケーションを使用して、クライアント サーバー アーキテクチャに接続しています。基本的に、このアプリケーションは多くの接続を作成し、ジョブが完了すると自動的に閉じます。例外が発生しています
「com.sshtools.j2ssh.transport.TransportProtocolException: 接続が完了しませんでした」
j2ssh ログを有効にして、問題の根本原因を突き止めました。以下は、この問題に関する完全な詳細です。
Java バージョン: jdk1.6.0_11
使用する API : J2SSH コア 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)
........と次のコード
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();
}
}
このエラーを克服する方法はありますか? この種のエラーにより、アプリケーションの sftp セッションが 1 つ失敗するため、これに対する解決策は何ですか?