我使用的是单线程应用程序连接我的客户服务器结构。基本上这个应用程序将创建许多连接&一旦工作完成后自动关闭它。我们正在一个异常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