uttamgupta commented on issue #658:
URL: https://github.com/apache/mina-sshd/issues/658#issuecomment-2751940065
I have another question related to SFTP client. It would be great if there
is question answer tab like issues. Actually I am facing some issue when we
upload download from several threads (~10) then some time I get exception
DefaultOpenFuture[SftpChannelSubsystem[id=18,
recipient=-1]-ClientSessionImpl[root@<serverip>:22][sftp]]: Failed
(SshChannelOpenException) to execute: open failed and sometime Channel id=9 not
registered because session is being closed: SftpChannelSubsystem[id=9,
recipient=-1]-ClientSessionImpl[<serverip>:22][sftp].
I know that I am not handling properly. Can you help on this? See code
snippet below-
`private SftpClient getSftpClient() throws SshClientException {
int count = 1;
SftpClient sftpClient = null;
while (count <= 3 && (sftpClient == null)) {
try {
sftpClient =
SftpClientFactory.instance().createSftpClient(getSession());
System.out.println("Created sftp client");
} catch (Exception e) {
System.out.println("Failed to create sftp client");
if (count == 3) {
throw new SshClientException(
hostname, "Failed to create sftp client after
multiple retry ", e);
}
try {
System.out.println("Waiting 2 seconds to create sftp
client");
Thread.sleep(2000);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
++count;
}
}
return sftpClient;
}
//Using here -
private void upload(final InputStream localInputStream, final String
remoteFile) {
try (SftpClient sftpClient = getSftpClient()) {
System.out.println("Sftp Id: " + sftpClient);
sftpClient.put(localInputStream, remoteFile);
} catch (IOException e) {
throw new SshClientException(
hostname, "Failed to upload file to " + remoteFile + "
via ssh", e);
// throw new
VcfSshException(VcfSshErrorCodes.FILE_UPLOAD_FAILED.withArgs(destinationPath),
// e);
}
}
`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]