Izu*_*uel 3 delphi ftp indy delphi-xe2
我在使用TidFTP组件时遇到了问题.
我可以使用这样的代码连接服务器
vFileList := TStringList.Create;
oClientFTP := TidFTP.Create(nil);
oClientFTP.Port := PortFTP;
oClientFTP.Host := IPHost;
oClientFTP.UserName := UserFTP;
oClientFTP.Password := PasswordFTP;
Run Code Online (Sandbox Code Playgroud)
从元素序列中获取多个文件后(这个元素正好有778个元素).检索到137,异常EIdAcceptTimeout以"Accept timed out"引发.信息.
我运行的代码是这样的(顺便说一下在线程中运行)
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;
Run Code Online (Sandbox Code Playgroud)
异常后,文件正确下载,但每个文件的过程需要25秒(我正在下载2KB的png图像).
知道这个例外的含义吗?
谢谢
谷歌搜索EIdAcceptTimeout导致Indy论坛的讨论:
在TIdFTP(client)中使用HOST => EIdAcceptTimeout
Remy Lebeau在哪里说:
数据传输期间唯一可能发生异常的情况是,如果您将TIdFTP.Passive属性设置为False,则告知FTP服务器与TIdFTP建立入站连接.这些连接通常被不支持FTP的防火墙/路由器阻止.当您在防火墙/路由器后面时,通常必须设置TIdFTP.Passive = True.
因此,解决方案可能是您添加一行
oClientFTP.Passive := True;
Run Code Online (Sandbox Code Playgroud)
顺便说一句.在您的代码片段中,您同时拥有oClientFTP和oClienteFTP.如果需要,调整我的建议.
| 归档时间: |
|
| 查看次数: |
2048 次 |
| 最近记录: |