我使用的是單線程應用程序連接我的客戶服務器結構。基本上這個應用程序將創建許多連接&一旦工作完成後自動關閉它。我們正在一個異常J2SSH ssh客戶端斷開頻繁
「com.sshtools.j2ssh.transport.TransportProtocolException:連接沒有完成」
我們已經啓用J2SSH日誌以找出問題的根本原因。以下是有關該問題的完整詳情。
Java版本:jdk1.6.0_11
API使用:J2SSH核心0.2.9(J2SSH核心-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會議失敗了,究竟是什麼解決辦法嗎?
Java SE 6的更新11發行日期2008-12-03 ==,J2SSH發佈日期2009年5月19日 - 時間新的東西? – 2015-03-25 06:04:59
嘗試使用jsch,它奇妙地工作 – 2015-03-25 06:05:55
感謝您的建議Wombat ..)我也試過更新到Java 7。但同樣的問題發生。如果沒有辦法,我只需要試試jsch .. – 2015-03-25 06:13:32