Search code examples
javascpapache-sshd

How can increase the wait timeout for ChannelOutputStream for scpClient of apache SSHD because of SocketTimeoutException?


When using apache SSHD scp client to copy files from local to remote, I get the following error:

flush(ChannelOutputStream[ChannelExec[id=0, recipient=0]-ClientSessionImpl[[email protected]/192.163.23.68:45018]] SSH_MSG_CHANNEL_DATA) failed (SocketTimeoutException) to wait for space of len=24576: waitForCondition(Window[client/remote](ChannelExec[id=0, recipient=0]-ClientSessionImpl[[email protected]/192.163.23.68:45018])) timeout exceeded: 30000

Here is how I have set up the SSHServer and the ScpClient:

How to upload/download files using apache SSHD ScpClient

This SCPClient is running in a linux host and there are multiple SSHServers that are running amongs linux and windows hosts.

I use this SCPClient to copy files to both linux and win SSHServers. What I am doing is I create some 20 odd akka actors that take care of copying to the respective remote hosts which are a combination of win and linux. So this does put some strain on the localhost when copying.

However I get this error only when copying to some WIN servers in which the SSHServer is running.

I did notice the copying is very slow but I am not sure what exactly is the issue and how I can fix it?

I have a vague idea that it has to do something with this param:

https://github.com/apache/mina-sshd/blob/sshd-2.5.0/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java#L43

But I am not exactly sure where I can configure this when creating the client?

any pointers would be helpful.


Solution

  • We can use the PropertyResolverUtils to update properties of any config

    PropertyResolverUtils.updateProperty(sshClient, ChannelOutputStream.WAIT_FOR_SPACE_TIMEOUT, 120000);