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

"Stop working" can mean that the server doesn't respond or that the server closes the connection.

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

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

SFTP:

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

1) pipelining (sending multiple SSH packets at once) which is not handled properly by many servers. SecureBlackbox disables pipelining for servers known to be buggy, but we can't test all versions of all servers (and each server has a different set of standard compliance problems in each of its versions). To disable pipelining by hand set AutoAdjustTransferBlock property to false and PipeLineLength property to 1.

2) The invalid path specified for the operation. First of all, you must ensure that the path is absolute. On Unix / Linux and on most Windows servers this means that the path must start with / (slash). Example: /path/to/filename.ext . Also, the path must exist. Neither SecureBlackbox nor the server creates the path for you. If the path doesn't exist, you need to create it.

3) Some servers incorrectly implement file transfer, when negotiated SFTP version is higher than SFTP 3. Try setting Versions property of the SFTP client to SFTP3 (numeric value 8).

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now