The SSH or SFTP connection to the server is closed or hangs during the data transfer stage (after a successful handshake). What should I do?

In this scenario, it's likely that the server isn't responding or that the server closes the connection.

If the server closes the connection, you need to implement an event handler for the OnError event of the client component. Then, if the closed connection was accompanied by an SSH error message from the server, you will get information on what caused the problem.

If the connection is closed silently (without any error message), this can happen due to inactivity (some servers close the connection after a certain period of user inactivity). Sending keep-alive packets using the SendKeepAlive() method should prevent this. Some buggy servers including FreeSSHd tend to "sleep" sometimes and not send the data. Try the SendKeepAlive() method on them too.


The most common sources of the problem during an SFTP connection are the following:

  1. pipelining (sending multiple SSH packets at once): This is not handled properly by many servers. SecureBlackbox disables pipelining for servers known to be buggy, but your version may not have been tested (and each server has a different set of standard compliance problems in each of its versions). To disable pipelining by hand set the AutoAdjustTransferBlock property to false and the PipeLineLength property to 1.
  2. Invalid paths: You must ensure that the path is absolute. On Unix, Linux, and most Windows servers this means that the path must start with / (slash). Example: /path/to/filename.ext. Also, the path must exist.
  3. File transfer problems: Some servers incorrectly implement file transfer when the negotiated SFTP version is higher than SFTP 3. Try setting the Versions property of the SFTP client to SFTP3 (the numeric value 8).

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now