Archived Forum Post

Index of archived forum posts


KeepAlive for FTP?

Jan 12 '13 at 15:10

We’re having issues with transferring files.

It seems that the FTP is failing because PORT 21 is not staying alive past 300 seconds.

Is there a means to include a KEEPALIVE clause in our SQL Scripts to keep port 21 alive past 300 seconds?


how can this be done while it is uploading a file? ftp2.PutFile() is blocking the thread.


In general, this shouldn't be a problem. Chilkat automatically uses the SO_KEEPALIVE socket option for the control connection. Therefore, at the TCP/IP networking level, the connection should remain alive even for long transfers.

The FTP protocol works as follows for a data transfer:

1) Client sends the appropriate command, such as STOR or RETR, on the command channel.

2) The data connection is established and the FTP server sends a preliminary reply on the control connection.

3) The data transfer occurs.

4) The server sends the final reply on the control connection.

This implies two things:

1) The FTP server certainly wouldn't close the control connection because it knows a transfer is in progress and once complete, it must send the final reply.

2) Additional control-channel commands cannot be sent while a data transfer is in progress. This would interfere with the state of the control channel -- namely that the client expect the next reply to be the final reply for the data transfer, and the server is not expecting new commands until the transfer is complete.

If the SQL Server is somehow interfering with the FTP control connection, then the solution would probably come from some sort of SQL Server setting, configuration, etc. I really don't know enough about SQL Server to know, or even if SQL Server would actually interfere with an FTP control connection. For example -- how would it even know such a connection exists? (because the connection is something that occurs within the Chilkat object and is not exposed to the caller)


One possible solution is to periodically send a NOOP command to the FTP server. You can do this by calling the ftp2.Noop() method.