zoukankan      html  css  js  c++  java
  • 解决 NET FTP Response error: (503) .

    1. 在应用。NET 访问FTP的Response来返回时,出现了如下错误。

    2. 参考如下MSDN 和一些网络资源,尝试后解决了此问题.

       > Ftp GetFileSize randomly throws FTP error 503 (Bad Sequence of Commands)

       >FtpWebRequest re-sending USER and PASS commands half way through download loop

    3. 问题是在此处应用此个FTP Request 之前曾经使用些地址创建了一个登录Session, 所以在后面同一地址会话建立时会有这个异常报告。

    The remote server returned an error: (503) Bad sequence of commands.

     解决办法就是将 request 对象的 KeepAlive 设为 False,其后基于同一IP创建的Session将不会抛出异常了。

    代码
    FtpWebRequest reqFTP;
                        reqFTP 
    = (FtpWebRequest)FtpWebRequest.Create(new Uri(sUnixURL));//"ftp://" + "10.2.159.69" + "/" + fileInf.Name));
                        reqFTP.Credentials = new NetworkCredential("dwei""Admin98");
                        reqFTP.Method 
    = WebRequestMethods.Ftp.DownloadFile;
                        reqFTP.UseBinary 
    = true;
                        reqFTP.KeepAlive 
    = false;   // If keepalive is true will make the same IP request response lead to failed !
                        FileStream outputStream = new FileStream(FILE_NAME, FileMode.Create);
                        
    // Create the writer for data.
                        BinaryWriter w = new BinaryWriter(outputStream);
                        FtpWebResponse response 
    = (FtpWebResponse)reqFTP.GetResponse();

    - Make people around you successful is the biggest contribution to ourselves. -

  • 相关阅读:
    springcloud配置中心
    burnside+polya 整理
    线段树-小总结
    D. Artsem and Saunders
    444 D. Ratings and Reality Shows
    P1337 [JSOI2004]平衡点 / 吊打XXX
    Typora + Open Live Writer 管理博客园
    旋转卡壳
    B. Alyona and a tree
    set的用法
  • 原文地址:https://www.cnblogs.com/zencorn/p/1725406.html
Copyright © 2011-2022 走看看