SecureBlackbox 16: 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?
Note: This article applies only to SecureBlackbox Legacy. For future development please consider using the latest version.
In this scenario, it is likely that the server is not responding or that the server is closing the connection. If the server is closing the connection, you need to implement an event handler for the OnError event of the client component.
The server may or may not close the connection with a useful SSH error message. 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:
- 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.
- 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.
- 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).
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at firstname.lastname@example.org.