服务器响应于PASV命令比向其中所作的FTP连接的地址不同返回地址 [英] The server returned an address in response to the PASV command that is different than the address to which the FTP connection was made

查看:794
本文介绍了服务器响应于PASV命令比向其中所作的FTP连接的地址不同返回地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


System.Net.WebException:服务器响应于PASV命令比向其中所作的FTP连接的地址不同返回地址结果,
。在系统.Net.FtpWebRequest.CheckError()结果
在System.Net.FtpWebRequest.SyncRequestCallback(obj对象)结果
在System.Net.CommandStream.Abort(例外五)结果
。在System.Net.FtpWebRequest.FinishRequestStage(RequestStage阶段)结果
在System.Net.FtpWebRequest.GetRequestStream()结果
在BackupDB.Program.FTPUploadFile(字符串SERVERPATH,字符串serverFile,FileInfo的LOCALFILE,的NetworkCredential中房)在D:\PROJEKTI\BackupDB\BackupDB\Program.cs:行119




代码:

  FTPMakeDir(新的URI(SERVERPATH +/),中房); 
的FtpWebRequest请求=(的FtpWebRequest)WebRequest.Create(SERVERPATH + serverFile);
request.UsePassive = TRUE;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials =中房;
字节[]缓冲区=新的字节[10240] //读取/写入10KB
$ B $使用B(的FileStream的SourceStream =新的FileStream(
LocalFile.ToString(),FileMode.Open))使用(流requestStream
{
= request.GetRequestStream())
{
INT读取动作;

{
读取动作= sourceStream.Read(缓冲,0,buffer.Length);
requestStream.Write(缓冲液,0,读取动作);
}当(读取动作大于0);
}
响应=(FtpWebResponse)request.GetResponse();
response.Close();
}


解决方案

如果任何人有同样的问题,这是为proftpd的溶液



http://www.proftpd.org/docs/howto/NAT.html


System.Net.WebException: The server returned an address in response to the PASV command that is different than the address to which the FTP connection was made.
at System.Net.FtpWebRequest.CheckError()
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetRequestStream()
at BackupDB.Program.FTPUploadFile(String serverPath, String serverFile, FileInfo LocalFile, NetworkCredential Cred) in D:\PROJEKTI\BackupDB\BackupDB\Program.cs:line 119

code:

FTPMakeDir(new Uri(serverPath + "/"), Cred);
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverPath+serverFile);
request.UsePassive = true;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = Cred;
byte[] buffer = new byte[10240];    // Read/write 10kb

using (FileStream sourceStream = new FileStream(
    LocalFile.ToString(), FileMode.Open))
{
    using (Stream requestStream = request.GetRequestStream())
    {
        int bytesRead;
        do
        {
            bytesRead = sourceStream.Read(buffer, 0, buffer.Length);
            requestStream.Write(buffer, 0, bytesRead);
        } while (bytesRead > 0);
    }
    response = (FtpWebResponse)request.GetResponse();
    response.Close();
}

解决方案

if anyone have the same problem, this is solution for proftpd

http://www.proftpd.org/docs/howto/NAT.html

这篇关于服务器响应于PASV命令比向其中所作的FTP连接的地址不同返回地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆