FTP - Get Errors

Giganews Newsgroups
Subject: FTP - Get Errors
Posted by:  DaveR (dav…@safeauto.com)
Date: Thu, 8 Feb 2007

Let me begin by saying I have spent many hours researching this problem before resulting to this post,
including purchasing Indy In Depth.
Currently I suspect there is a problem in Indy 10.1.5 GET procedure?  My code is currently running in
Indy 10.0.52.  When I attempt to run the same code in the newer version I recieve errors.
On GET I recieve "Destination File Already Exists" Error when I am certain it does not.  I believe I have found a work around for this by setting CanOverWrite to true and doing my own FileExists check, this seems to be a bug?
My current problem is a read timeout error on GET.  The server I am connected to requires the port to be 20021 passive mode.  As I step through the code I am seeing LPort with a different value, the IOHandler port is debugging with 20021. My understanding with passive is that everything occurs on one channel?  It appears a LPASSIVECL is being cretaed with a different port?
My code is as follows:
Prior to this procedure I have made a secure SSL conneciton and PUT a file on the server, I can also LIST the directory,
this works consistently well. I just cannot GET a file.

idFTP
ReadTimeOut = 0
DataPort - 20021
DataPortMax - 20021
DataPortMin - 20021
Passive = True
UseTLS = utUseExplicitTLS

idSSLIOHandlerSkt
Port - 20021
BoundPort - 20021
DefaultPort - 20021
Id_IPv4
sslvSSLv3

try
    if idFTP.Connected then
      begin
        idFTP.ChangeDir('/########');
        cxMemo.Lines.Add('Current Directory: ' + idFTP.RetrieveCurrentDir);  -- Confirmed current directory is correct.
        idFTP.List(Files, '*.*', True);                                      -- List works fine
        cxMemo.Lines.Add('File count: ' + IntToStr(Files.Count));
      end
    else
      begin
        SendMail(soDevError, 'Error occured FTP not connected ');
        Exit;
      end;

    if Files.Count > 1 then  // List will always contain the directory display file count record
      begin
        for i := 0 to Files.Count - 1 do
          begin
            cxMemo.Lines.Add('#' + IntToStr(i) + ': ' + Files.Strings[i]);
            if pos('Total number of batches',Files.Strings[i]) > 0 then        // FTP list directory will have a footer display
              begin                                                            // of number of files listed, remove it from the list
              Files.Delete(i);
              Continue;
              end;
          end;
        try
          if FileExists(FileName) then
            begin
              SendMail(soDevError, 'FIle already exists - ' +  FormatDateTime('MM DD, YYYY', Now),
                    ' File Already Exists -  ' + PayFileName + #13 +
                    ' To run more than one file on the same day, the file must be manually retrieved ' + #13 +
                    ' and processed.' );
              Exit;
            end;

          idFTP.Get('#########', PayFileName);
        except
          on E: Exception do
            begin
              SendMail(soDevError,  Run - ' + FormatDateTime('MMMM DD, YYYY', Now),
                    ' Get  File Error - ' + E.Message);
            end;
        end;
      end
    else
      begin
        cxMemo.Lines.Add('No files in directory');
        Exit;
      end;
  finally
    idFTP.Disconnect;
    Files.Free;
  end;

Any insight will be tremendously appreciated, Thanks!

Replies