1

I'm trying to send in-memory data as a file to remote server by using org.apache.sshd.client.

My code so far:

// Connect to remote server code
sftp = session.createSftpClient();
StringBuilder sb = new StringBuilder();
for (int j = 0; j < 1000; j++) {
    sb.append("a");
}

byte[] data = sb.toString().getBytes(StandardCharsets.UTF_8);
sftp.write(h, 0, data, 0, data.length);

Every things are fine until i try to make my input data bigger. I set loop count from 1000 to 1000000. And it's keep throwing following exception:

org.apache.sshd.common.SshException: Channel has been closed

.

I try to set SFTP's [channel open timeout] more bigger but can not resolve this problem.

So I realized that any time data size greater than 256KB, the exception will be thrown. I tried to edit IO Buffer size, Write buffer, Read buffer but the problem is still there.

Is there any way to setting data size or any way to solve this problem? Thanks you all in advance.

Abhijeet Kale
  • 1,656
  • 1
  • 16
  • 34
Minh
  • 424
  • 3
  • 12

0 Answers0