Archived Forum Post

Index of archived forum posts


Is it allowed to connect only once to an SFTP server and use that connection for a long period?

Jun 02 '16 at 19:28


I am using the ActiveX SFTP component in my software (an xml editor).

In the old source code, each time i wanted to create a file on an SFTP server i called SFTP.connect() and then SFTP.CreateFile(). During testing i noticed that connecting to the SFTP server (SFTP.connect()) takes a lot of time, compared to actually creating the file.

So, i changed the source code: now, SFTP.connect() is called only once (per server) and CreateFile() is called many times. This solution is much much faster.

My question is this: is this allowed? Is there a situation where the connection to the server is dropped (maybe if there isn't any traffic for a few minutes?) and i have to call SFTP.connect() again. If so, how do i detect such a situation? Or does the SFTP component automatically takes care of such a situation?

Thank you, - Gerben


The logic should be connect, and send all the files. If the connect is taking a long time, you have DNS resolve issues.

Depends on the server, the other side. Most disconnect if no traffic, others do not. The is a isConnected method, although I thought that it was depreciated, and should use a checkConnection method. Shows in ftp, but isConnected is still on sftp. Read the note. That is one of the things I do not like. Both sftp and ftp should be combined, and protocol passed as an argument.

You will have to check the status of CreateFile. There should be a error for what you are describing.


Where do you find CreateFile????