gpt4 book ai didi

c# - GetWebResponse 在 Windows 7 上非常慢

转载 作者:太空宇宙 更新时间:2023-11-03 13:42:47 25 4
gpt4 key购买 nike

我已经尝试了所有的设置,我在互联网上发现可以使 C# webclient 在 Windows7 机器上运行得更快无济于事。 Windows XP 机器上的相同 exe 对每个请求的响应时间少于 100 毫秒。

我已经覆盖了派生类中的 GetWebRequest 函数System.Web.Services.Protocols.SoapHttpClientProtocol

    protected override WebRequest GetWebRequest(Uri address)
{
//ServicePointManager.UseNagleAlgorithm = false;
HttpWebRequest.DefaultWebProxy = null;
ServicePointManager.DefaultConnectionLimit = 4096;
ServicePointManager.Expect100Continue = false;
System.Net.ServicePointManager.CheckCertificateRevocationList = false;
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
request.Proxy = HttpWebRequest.DefaultWebProxy;

return (WebRequest)request;
}

protected 覆盖 WebResponse GetWebResponse(WebRequest 请求) {

        HttpWebResponse response = null;
//HttpWebRequest.DefaultWebProxy = null;
//ServicePointManager.Expect100Continue = false;
response = (HttpWebResponse)base.GetWebResponse(request);
return response;
}

我还在 machine.config .Net4.0 文件夹中添加了套接字跟踪设置它总是在输出窗口中等待下面的语句 7-15 秒

System.Net.Sockets Verbose: 0 : [6088] Socket#54042743::Receive()

希望一些冠军已经解决了这个问题

最佳答案

尝试使用 GetResponse 类并检查您是否发现一些差异:

HttpWebRequest wrequest = (HttpWebRequest) WebRequest.Create(objeto.Url);

//Get Response
HttpWebResponse wresp = (HttpWebResponse) wrequest.GetResponse();

//get Response Stream
StreamReader sr = new StreamReader(wresp.GetResponseStream());

//Get string content
string respuestastring = sr.ReadToEnd();

关于c# - GetWebResponse 在 Windows 7 上非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16392764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com