2

Clients periodically send data to server TIdFtpServer in passive mode. In one client machine, where network sometime is breaking I got message:

EIdReplyRFCError : File status okay; about to open data connection.

And next commands also throw exception like: EIdReplyRFCError : Requested action aborted: local error in processing.

When any EIdException apperar then clear socket like:

if Assigned(FFtp.IOHandler) then
begin
  FFtp.IOHandler.InputBuffer.Clear;
  FFtp.IOHandler.Close;
end;
FFtp.KillDataChannel;

But client cannot longer send data, still EIdReplyRDCError is throwing and I must restart Server FTP. After restart then client reconnect succesfully and can send data. In the server side, I don't logged any uncatched exceptions.

I tried also at the server side, kill clients which no send data over 20 minutes:

try
  T := FFtpServ.Contexts.LockList;
  for I := 0 to T.Count - 1 do
  if TIdFtpServerContext(T[I]).Data <> nil then
  begin
    Cl := TFtpCl(TIdFtpServerContext(T[I]).Data);

    Minutes := MinutesBetween(Cl.LastPing, Now);
    if Minutes >= 20 then
    begin
      if(Assigned(TIdFtpServerContext(T[I]).Connection.IOHandler)) then
      begin
        TIdFtpServerContext(T[I]).Connection.IOHandler.InputBuffer.Clear;
        TIdFtpServerContext(T[I]).Connection.IOHandler.Close;
      end;
      TIdFtpServerContext(T[I]).KillDataChannel;
    end;
  end;
finally
  DM.FFtpServ.Contexts.UnLockList;
end;

But in this approach often I got AccessViolation exception.

Any idea to solve this problem?

4

2 回答 2

0

在 Contexts.UnLockList 之后。我认为在客户端池线程中抛出异常。

如何在服务器端正确断开指定客户端?

于 2012-11-01T10:26:41.583 回答
0

您所描述的表明 FTP 通信已不同步。 TIdFTP正在以错误的顺序处理服务器响应。您能做的最好的事情就是让客户端断开连接并重新连接。您不必在服务器端做任何事情。

于 2012-11-01T20:45:28.727 回答