Reputation: 167
I had been trying to get a file from a ftp server, but everytime a try to connect using my code i've got the same error:
EIdSocketError: Socket Error # 10060 Connection timed out.
using Filezilla 3.4, I can connect and download the files, my code:
var
objFTP: TidFTP;
begin
try
objFTP := TIdFTP.Create;
try
objFTP.Disconnect;
objFTP.Host := '200.1.81.252';
objFTP.Port := 990;
objFTP.Username := 'user_name';
objFTP.Password := 'user_pass';
objFTP.Passive := True;
objFTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(objFTP);
objFTP.UseTLS := utUseRequireTLS;
objFTP.TransferTimeout := 120000;
try
objFTP.Connect;
objFTP.ChangeDir('/salida/acciones/2015-05-20');
objFTP.Get('SW052015.003', 'C:\SW052015.txt');
finally
objFTP.Disconnect;
end;
finally
FreeAndNil(objFTP);
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
any suggestions?
Configurations on FileZilla:
Authentication port: 990
Data transfer port: 9080 (don't know what this is)
Encryption: Required explicit FTP over TLS
Passive mode
Force UTF-8
Upvotes: 2
Views: 8216
Reputation: 167
Thanks to the comments, I've got the code working great:
var
objFTP: TidFTP;
sCaminho: String;
begin
sCaminho := 'C:\SW052015.txt';
SysUtils.DeleteFile(sCaminho);
try
objFTP := TIdFTP.Create;
try
objFTP.Host := '200.1.81.252';
objFTP.Username := 'user_name';
objFTP.Password := 'user_pass';
objFTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(objFTP);
objFTP.UseTLS := utUseExplicitTLS;
objFTP.DataPortProtection := ftpdpsPrivate;
try
objFTP.Port := 990;
objFTP.Passive := True;
objFTP.Connect;
objFTP.ChangeDir('/salida/acciones/2015-05-20');
objFTP.Get('SW052015.003', sCaminho);
finally
objFTP.Disconnect;
end;
finally
FreeAndNil(objFTP);
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Upvotes: 2