Downloading list of files from remote FTP

delphi, delphi-xe2, ftp, indy

Solution

Googling for `EIdAcceptTimeout` leads to this discussion in the Indy forum:

UseHOST in TIdFTP (client) => EIdAcceptTimeout

Where Remy Lebeau states:

The only time that exception can occur during a data transfer is if you have the TIdFTP.Passive property set to False, which tells the FTP server to make an inbound connection to TIdFTP. Those connections are usually blocked by firewalls/routers that are not FTP-aware. You usually have to set TIdFTP.Passive=True when you are behind a firewall/router.

So, the solution could be for you to add a line

oClientFTP.Passive := True;

Btw. In your code snippets you have both oClientFTP and oClienteFTP. Adjust my suggestion if needed.

Problem

I'm getting a problem using the TidFTP component. I'm able to connect with the server using a code like this ``` vFileList := TStringList.Create; oClientFTP := TidFTP.Create(nil); oClientFTP.Port := PortFTP; oClientFTP.Host := IPHost; oClientFTP.UserName := UserFTP; oClientFTP.Password := PasswordFTP; ``` After getting several files from the StringList (this one has exactly 778 elements) when the element no. 137 is retrieved the exception EIdAcceptTimeout is raised with "Accept timed out." message. The code that I run is like this (runs in a Thread by the way) ``` procedure TDownloadFTP.Get; begin try for I := 0 to vFileList .Count - 1 do begin sFileName:= vFileList [I]; posPoint := LastDelimiter('.', sFileName); if posPoint = 0 then ForceDirectories(ExtractFilePath(Application.ExeName) + '/BackUp/' + sFileName) else try oClienteFTP.Get(sFileName,IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName) + '/BackUp/') + sFileName, True); except on E: EIdReplyRFCError do begin end; on E: Exception do exceptionList.Add(sFileName); end; end; ``` After the exception, the file is downloaded correctly but the process needs like 25 seconds per file (I'm downloading 2KB png images). Any idea of the meaning of this Exception? Thanks

Original source