当我尝试连接到(Windows)SFTP服务器时出现问题。 SFTP服务器的名称是Secure Bridge(适用于Windows)。 这很奇怪,因为它看起来有时正常工作,但有时也无法正常工作。它有时显示如下的错误。 我的来源如下。你可以帮帮我吗?为什么会出现此错误?
[Error]
java.io.IOException: The transport protocol disconnected
com.sshtools.j2ssh.transport.TransportProtocolCommon.readMessage(Unknown Source)
com.sshtools.j2ssh.transport.TransportProtocolCommon.sendNewKeys(Unknown Source)
com.sshtools.j2ssh.transport.TransportProtocolCommon.beginKeyExchange(Unknown Source)
com.sshtools.j2ssh.transport.TransportProtocolCommon.onMsgKexInit(Unknown Source)
com.sshtools.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol(Unknown Source)
com.sshtools.j2ssh.transport.TransportProtocolCommon.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
private SshClient client = null;
private PasswordAuthenticationClient auth = null;
private SftpClient sftp = null;
public boolean connect(String server,
int port,
String user,
String pwd) throws Exception {
try {
if (server == null || user == null || pwd == null) {
logger.error("Parameter is null!");
throw new Exception("Parameter is null!");
}
SshConnectionProperties params = new SshConnectionProperties();
params.setHost(server);
params.setPort(port);
HostKeyVerification key = new HostKeyVerification() {
@Override
public boolean verifyHost(String arg0,
SshPublicKey arg1) throws TransportProtocolException {
return true;
}
};
client = new SshClient();
client.setSocketTimeout(10000);
client.connect(params, key);
auth = new PasswordAuthenticationClient();
auth.setUsername(user);
auth.setPassword(pwd);
int result = client.authenticate(auth);
if (result != AuthenticationProtocolState.COMPLETE) {
throw new Exception("Login to " + server + ":" + port + " " + user + "/" + pwd + " failed");
}
sftp = client.openSftpClient();
} catch (Exception e) {
logger.error(e);
logout();
return false;
}
return true;
}
答案 0 :(得分:0)
看起来很难解决。我已将RAM大小从1G升级到3G。然后它正常工作。测试FTP服务器位于VMWare中。我不知道RAM Size与错误消息有关。所以这个错误与我的PC环境有关。
感谢。