远程服务器返回错误:227进入被动模式. [英] The remote server returned an error: 227 Entering Passive Mode.

查看:390
本文介绍了远程服务器返回错误:227进入被动模式.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之,
我正在尝试从ftp读取5000个xml文件,但它抛出
远程服务器返回错误:227在读取第1500个xml文件时进入被动模式(89,202,213,212,6,32).我该怎么办才能帮助我.


Briefly,
I''m trying to read 5000 xml files from ftp but it throws
The remote server returned an error: 227 Entering Passive Mode (89,202,213,212,6,32) on reading 1500th xml file. what shall i do somebody help me.


    string[] files;
    files = GetFileList();
    foreach (string file in files)
     {
      xmlDoc.Load("ftp.Test.com/stats/" + file);
      XmlNodeList itemNodes = xmlDoc.SelectNodes("//Sport");
    }    
    // on reading 1600th xml file i get the Exception like The remote server returned an error: 227 Entering Passive Mode (89,202,213,212,6,32)

public string[] GetFileList()
    {
        string[] downloadFiles;
        StringBuilder result = new StringBuilder();
        WebResponse response = null;
        StreamReader reader = null;
        try
        {
            FtpWebRequest reqFTP;
            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://ftp.Test.com/stats/"));
            reqFTP.UseBinary = true;
            reqFTP.Credentials = new NetworkCredential("Test", "Test");
            
            reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
            reqFTP.Proxy = null;
            reqFTP.KeepAlive = false;
            //reqFTP.EnableSsl = true;
            reqFTP.UsePassive = false;
            response = reqFTP.GetResponse();
            reader = new StreamReader(response.GetResponseStream());
            string line = reader.ReadLine();
            while (line != null)
            {
                result.Append(line);
                result.Append("\n");
                line = reader.ReadLine();
            }
            // to remove the trailing '\n'
            result.Remove(result.ToString().LastIndexOf('\n'), 1);
            return result.ToString().Split('\n');
        }
        catch (Exception ex)
        {
            if (reader != null)
            {
                reader.Close();
            }
            if (response != null)
            {
                response.Close();
            }
            downloadFiles = null;
            return downloadFiles;
        }
    }

推荐答案

在高负载情况下,服务器可能没有定义足够的数据端口来匹配请求,或者可能正在冒险进入数据端口范围再次无法在防火墙上打开.
In high load situations the server might not have enough data ports defined to match the requests, or it might be venturing into a data port range that once again is not open on the firewalls.


这篇关于远程服务器返回错误:227进入被动模式.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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