Ich habe ein Problem, wenn ich versuche, eine Verbindung zum (Windows) SFTP Server herzustellen. Der Name des SFTP-Servers lautet Secure Bridge (für Windows). Es ist seltsam, weil es irgendwann richtig funktioniert, funktioniert aber irgendwann auch nicht. Es zeigt Fehler wie unten manchmal. Meine Quelle ist unten. Kannst du mir helfen? Warum tritt dieser Fehler auf?SFTP Verbindungsfehler (Transportprotokoll getrennt)
[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;
}
Können Sie mit einem beliebigen SFTP-Client, z. B. filezilla, eine Verbindung zum selben Server herstellen? –