qq_40251936 2020-04-03 22:12
浏览 191

部分外网用户无法通过delphi做的程序连接ftp服务器,宽带不行,换成手机热点却可以

1.服务器上安装的filezilla程序,采取被动模式,做了动态域名映射,端口也都放开了
2.用delphi做的程序通过idftp连接ftp服务器,用来上传和下载文件
3.公司内部使用没有问题
4.外网用户通过浏览器,文件夹都可以正常访问公司的ftp服务器获取文件
但是有部分用户使用delphi开发的程序时,却连不上,奇怪的是他们把电脑
连上手机热点的网络后却可以正常使用。还有的之前用家里的网使用的一切正常,后来t突就然就连不上了

begin
  with TIdFTP.Create(nil) do
  try
    Port := gftp_port;
    Passive :=true;
    PassiveUseControlHost := true;

    Host := gFtpserver;
    Username := gftp_user;
    Password := gftp_pass;

    lst := TStringList.Create;

    try
      Connect;  //在这里报错

      cxm1.Lines.Clear;
      cxm1.Lines.Add('开始下载文件...');
      tblo.First;
      while not tblo.EOF do
      begin
        bc := tblo.FieldByName('bcode').Value;
        sp := Format('\Original\%s\%s\', [formatdatetime('yyyymmdd',tblo.FieldByName('bdate').AsDateTime), bc]);
        fd := cxbtndt1.Text;

        if tblo.FieldByName('file1').IsNull then
          sf := ''
        else
          sf := tblo.FieldByName('file1').Value;

        if sf <> '' then
        begin
          try
            //修改了文件名称,文件名称为订单ID+文件名称
            sf1 := tblo.FieldByName('wo_id').AsString + '_'+sf;
            if FileExists(fd+sf1) then DeleteFile(fd+sf1);

            Get(sp+sf, fd+sf1);
            //cxm1.Lines.Add(Format('%s 文件%s下载完成.', [bc, sf1]));
          except
            on e:Exception do
            begin
              if FileExists(fd+sf1) then DeleteFile(fd+sf1);
              cxm1.Lines.Add(Format('%s 文件%s不存在.', [bc, sf1]));
            end;
          end;
        end;
        tblo.Next;
        Application.ProcessMessages;
      end;
      cxm1.Lines.Add('文件下载结束.');

      OpenDialog(s, '浏览文件', '所有文件(*.*)', '*.*', true, fd);
    except
      on e: Exception do
      begin
        cxm1.Lines.Add('连接文件服务器错误:'+e.Message);
      end;
    end;
  finally
    if Connected then Disconnect;
    Free;
    lst.Free;
  end;

图片说明

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog