解决 NET FTP Response error: (503) .
来源:互联网 发布:linux 网络配置文件 编辑:程序博客网 时间:2024/06/05 04:01
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();
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();
- 解决 NET FTP Response error: (503) .
- ASP.NET WebService Response.Write乱码解决
- FTP的Response含义
- 使用Apache 的 FTP Client获取FTP服务器上的文件列表FTP response 421 received.Server closed connection问题的解决
- 使用Apache 的 FTP Client获取FTP服务器上的文件列表FTP response 421 received.Server closed connection问题的解决
- http response error
- Error response docker
- FASTDFS PYTHON [-] Error: response size not match, expect: 105, actual: 105 解决
- 解决drupal下使用composer时报错:Failed to decode response: zlib_decode(): data error
- The development server returned response error code: 500 in react-native怎么解决
- Net::FTP
- 利用org.apache.commons.net.ftp实现ftp下载,解决中文文件名乱码问题
- 解决Response中文乱码
- response跳转乱码解决
- response跳转乱码解决
- Response.ContentType (ASP.NET)
- Asp.Net Response.Redirect()
- .net 常用Response.ContentType
- Silk_ 运行时_控件_属性_捕捉.
- UNIX SSH 命令
- 使用 Windows service 访问域管理
- 访问 远程机 盘符 设置
- SQL Server 汉字 问号
- 解决 NET FTP Response error: (503) .
- [转 - 改] Perl初级教程 (一)
- [转 - 改] Perl初级教程 (二)
- 数学英语词汇
- [转 - 改] Perl初级教程 (三)
- SQL2008 T-SQL Note
- [转 - 改] Perl初级教程 (四)
- 解决 SQL Server Web Service is not configured.
- SQL Server DBCC & Count (*) Count(1) ,Select Count(column)