Archived Forum Post

Index of archived forum posts

Question:

does sftp.net have keep alive

Dec 07 '15 at 13:44

we use SFTP (C#) and one of the servers we send large files too would disconnect (timeout) in the middle of sending large files (say 15 GB)

we get a "SocketError: WSAECONNRESET An existing connection was forcibly closed by the remote host"

they said they have a 20 secs timeout for idle connections not sure why it becomes idle when it is already started to majority of the file they recommend setting/sending keep-alives but I do not see this option for SFTP

are they correct in asking for this? what are my options to be able to send these large files regularly


Answer

This is not a "keepalive" problem. There are two possible "keep alives" --

  1. The SO_KEEPALIVE socket option. This is a TCP/IP socket option that can apply to any TCP connection (it is not specific to SSH/SFTP). The TCP connections Chilkat makes should have SO_KEEPALIVE turned on automatically. In any case, this only comes into play when there is no activity on the TCP connection. When a transfer is ongoing, there is (of course) plenty of activity and therefore this keepalive never comes into play..
  2. Inactivity on the SSH connection: This is where an SSH server might automatically shutdown a client connection when there is no activity (i.e. no SSH messages) for some period of time. During an SFTP transfer, there is plenty of SSH message chatter (because transfer happen in discrete messages and each message containing data requires an SSH ack message, so SSH chatter is bidirectional during the entire transfer). During a file transfer, the SSH connection is very much active, and therefore it cannot be a "keepalive" problem due to inactivity.