EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Connection to standard FTP Server doesn't quite work

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#23117
Posted: 01/10/2013 08:40:28
by Anton Kufer (Standard support level)
Joined: 12/18/2012
Posts: 16

when i try to connect and work with a standard (non-Secure) FTP server i always get an error message when i try to change dir or get the current dir.

it always says: unaccepted server reply (error code is 220).

Code
  t_FTP := TElSimpleFTPSClient.Create(Self);
  try
    t_FTP.Name := 'tempFTPSContainerFTPAbholen';

    t_FTP.Address  := 'ftp.mburgst.de';
    t_FTP.Port     := 21;
    t_FTP.Username := 'xxxxx';
    t_FTP.Password := 'xxxxx';

    t_FTP.ProxySettings.Host := '192.168.0.254';
    t_FTP.ProxySettings.Port := 2121;
    t_FTP.ProxySettings.Username := '';
    t_FTP.ProxySettings.Password := '';
    t_FTP.ProxySettings.ProxyType := ptOpen;

    t_FTP.UseSSL := false;
    t_FTP.Versions := [];

    t_FTP.SocketTimeout := 60000;
    t_FTP.TransferTimeout := 60000;
    t_FTP.ListenTimeout := 60000;

//  t_FTP.CompressionAlgorithms[SSH_CA_ZLIB] := true;

    t_FTP.Open;
    if t_FTP.Active then
    begin
      t_RemoteDir := t_FTP.GetCurrentDir;
      ShowMessage(t_RemoteDir);

      t_Dateien := TList.Create;
      try
        t_FTP.ListDirectory(t_RemoteDir,t_Dateien,'',false,true,true);
        for i := 0 to pred(t_Dateien.Count) do
        begin
          t_Str := TElFTPFileInfo(t_Dateien[i]).Name;
          Memo1.Lines.Add(t_Str);
        end;
      finally
        FreeAndNil(t_Dateien);
      end;

      t_FTP.Cwd(t_RemoteDir);
      try
        t_Dateien := TList.Create;
        t_FTP.ListDirectory(t_RemoteDir,t_Dateien,'*.xml',false,true,false);
        for i := 0 to pred(t_Dateien.Count) do
        begin
          WriteToLog('FTP','ContainerFTPAbholen','Dir Inhalt: '+TElSftpFileInfo(t_Dateien.Items[i]).Name,'');
        end;

        for i := 0 to pred(t_Dateien.Count) do
        begin
          t_RemoteFile := TElFTPFileInfo(t_Dateien.Items[i]).Name;
          if pos('.xml',AnsiLowercase(t_RemoteFile))>0 then
          begin
            t_LocalFile := IncludeTrailingBackslash(t_LocalDir)+ExtractFilename(t_RemoteFile);

            t_RemoteFile := t_RemoteDir+'/'+t_RemoteFile;

            WriteToLog('FTP','ContainerFTPAbholen',t_RemoteFile+' herunterladen '+t_LocalFile,'I');
            t_FTP.DownloadFile(t_RemoteFile,t_LocalFile,ftmOverwrite);
            WriteToLog('FTP','ContainerFTPAbholen',t_RemoteFile+' heruntergeladen nach '+t_LocalFile,'I');

            if t_FTP.GetRemoteChecksum(t_RemoteFile,cmCRC)=t_FTP.GetLocalChecksum(t_LocalFile,cmCRC) then
            begin
              WriteToLog('FTP','ContainerFTPAbholen','Checksumme identisch','I');
            end;

            t_FTP.Delete(t_RemoteFile);
            WriteToLog('FTP','ContainerFTPAbholen',t_RemoteFile+' gelöscht','I');

            t_Anmeldungen.Add(t_LocalFile);
          end;
        end;
      finally
        FreeAndNil(t_Dateien);
      end;

      t_FTP.Close;
      WriteToLog('FTP','ContainerFTPAbholen','FTP Verbindung geschlossen!','I');
    end;
  finally
    if t_FTP.Active then
    begin
      t_FTP.Close;
    end;


can SecureBlackbox only connect to secured FTP servers? i'd like to handle every kind of connection via secureblackbox to keep the code variations tight.

strange enough ftps needs proxy informations, sftp doesn't. it seems there's some completely different code behind?

can't ftps automatically detect and use the proxy?
#23120
Posted: 01/10/2013 09:18:46
by Ken Ivanov (EldoS Corp.)

Anton,

You are missing a call to the Login() method in your code. The component doesn't perform authorization implicitly, you always need to force it explicitly with a Login() call. A typical place to call Login() is just after the Open() call succeeds.

Quote
strange enough ftps needs proxy informations, sftp doesn't. it seems there's some completely different code behind?

As a matter of fact, yes, SFTP and FTPS are completely different protocols with their own peculiarities. Particularly, there is a concept of "FTP proxy". On the other hand, both protocols can work through universal SOCKS and WebTunnel proxy servers.

Quote
can't ftps automatically detect and use the proxy?

No, it is a task of the user to provide proxy information to the component.
#23122
Posted: 01/10/2013 09:29:53
by Anton Kufer (Standard support level)
Joined: 12/18/2012
Posts: 16

ah well, ok. included that.

now when i call LOGIN directly after the OPEN i get an 530 error code.

when i call it after the t_FTP.ACTIVE i get a 501 error.

is this a problem with the proxy?
#23124
Posted: 01/10/2013 09:48:54
by Ken Ivanov (EldoS Corp.)

Anton,

According to the replies you get from the server, your authorization procedure fails. First of all, please re-check the correctness of the values assigned to the Username and Password properties.

BTW, what type of proxy do you need to direct connections through?
#23126
Posted: 01/10/2013 10:05:27
by Anton Kufer (Standard support level)
Joined: 12/18/2012
Posts: 16

it seems it was the proxytype that caused the problem. i changed it to ptUserSite and now it works. *sigh*
#23127
Posted: 01/10/2013 10:11:46
by Ken Ivanov (EldoS Corp.)

Perfect, thank you for keeping us informed.
Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.

Reply

Statistics

Topic viewed 1554 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!