日期:2014-05-20  浏览次数:21066 次

WebRequest 使用代理 Post 超时问题
多线程使用webrequest 使用代理访问  get 基本上没有超时现象,但是在post操作的时候总是超时异常!
这是对方服务器限制?还是我使用有误?

 byte[] data = encoding.GetBytes(rushdata);
            request = WebRequest.Create(PostUrl) as HttpWebRequest;//************ 
            request.Method = "POST";          
            request.ContentLength = rushdata.Length;
            request.Timeout = 20000;            
            request.Accept = "*/*";            
            request.Headers.Add("X-Requested-With", "XMLHttpRequest");
            request.UserAgent = UA;
            request.ContentType = "application/x-www-form-urlencoded";
            request.Referer = ReferUrl;           
            request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8");
            request.Headers.Add("Accept-Charset", "GBK,utf-8;q=0.7,*;q=0.3");          
            request.CookieContainer = PostCookie;           
            request.Proxy = new WebProxy(_ip, int.Parse(_port));//使用代理
            outstream = request.GetRequestStream();
            outstream.Write(data, 0, rushdata.Length);
            outstream.Close();
            response = request.GetResponse() as HttpWebResponse;
            instream = response.GetResponseStream();
            if (response.ContentEncoding != null && response.ContentEncoding.Equals("gzip", StringComparison.InvariantCultureIgnoreCase))
                sr = new StreamReader(new GZipStream(instream, CompressionMode.Decompress), encoding);
            else
                sr = new StreamReader(response.GetResponseStream(), encoding);
            content = sr.ReadToEnd();

------解决方案--------------------
应该是代理本身的问题