Search code examples
delphiftpindy10

TIdFtp in Delphi XE2 - connect method very slow


I'm using TIdFTP (Indy 10.2) in Delphi XE2; the method 'connect' (to create a connection...) is very slow; it takes 7 - 8 seconds to accomplish task. I have tried with different configurations: Passive true or false, AutoLogin true or false, but more or less the same situation. Is there any particular configuration to consider ?


Solution

  • First, 10.2 is a VERY OLD and OUTDATED version. The current version is 10.6. You should seriously consider upgrading.

    Second, Connect() does a lot of work. It always sends a SYST command at a minimum, but depending on the values of the following properties, it may send a lot of additional commands as well:

    • UseHOST=True
      HOST
      
    • AutoLogin=True
      AUTH 1-4 times (only if UseTLS is utUseRequireTLS or utUseExplicitTLS)
      XAUT (only if ProxySettings.ProxyType is fpcmNone)
      USER
      PASS
      ACCT
      OPEN (only if ProxySettings.ProxyType is fpcmOpen)
      EPSV ALL (only if EPSV is supported)
      SITE ZONE (only if SITE ZONE is supported)
      TYPE
      
    • AutoIssueFEAT=True
      FEAT
      CLNT
      

    So taking 7-8 seconds to complete is not unreasonable depending on how many commands it has to send and how much bandwidth you have available. To make Connect() return as soon as possible, turn off all of the auto features, and then call Login() and IssueFEAT() manually when ready.