I have been using SSHJ to write files to my remote SFTP server. The current set up is I have a Spring Batch ItemWriter that writes chunks of data arbitrarily to a file. Jsch does not support this feature as if the chunks come in out of order then the file is corrupted as the chunks got written out of order, this is why I have turned to SSHJ.
The problem comes in with the size of the data chunks. Currently any size above 32KB breaks the transfer instantly with the following exception.
net.schmizz.sshj.connection.ConnectionException: Timeout when trying to expand the window size
My goal is to maximize the throughput of my file transfer as much as possible and generally this done is by increasing the window size or the packet size. The issue is despite increasing both on the client and Socket I get the following exception
After reading the SSH RFC it states that the maximum window size can be up to `2^32-1 roughly equal to 4.29GB. So if I set the buffer size and the window size to be the max possible 2^32-1 the transfer should work but the exception above comes up.
Here is the current client configuration
SSHClient sshClient = new SSHClient();
Connection conn = sshClient.getConnection();
conn.setWindowSize(dataChunkSize);
sshClient.addHostKeyVerifier(new PromiscuousVerifier());
sshClient.connect(destCredUri[0], Integer.parseInt(destCredUri[1]));
Socket socket = sshClient.getSocket();
socket.setTcpNoDelay(true);
socket.setKeepAlive(true);
socket.setSendBufferSize(Math.toIntExact(dataChunkSize));
socket.setReceiveBufferSize(Math.toIntExact(dataChunkSize));
How can I increase the chunk size above 32KB? On the side any advice on maximizing throughput over SFTP would be amazing.
Thank you very much in advance.