开发者

HttpWebRequest issues

开发者 https://www.devze.com 2022-12-25 23:02 出处:网络
Im still having issues using HttpWebRequest. For some reason sometimes in my app the call just times out...

Im still having issues using HttpWebRequest.

For some reason sometimes in my app the call just times out...

HttpWebRequest req = null;
req =
   (HttpWebRequest)WebRequest.CreateDefault(new Uri(aRequest));
req.PreAuthenticate = true;
req.AllowAutoRedirect = true;
req.KeepAlive = false;

.....

resp = (HttpWebResponse)req.GetResponse();
resp.close();

I am closing the response but Im just wondering if it is more likely to fail since Im ma开发者_高级运维king requests all over the place?

I tried playing around with the ServicePointManager class hoping it would help but it hasnt really

System.Net.ServicePointManager.DefaultConnectionLimit = 100;
System.Net.ServicePointManager.MaxServicePoints = 100;


The best approach is to go after the timeout and understand why it timed out. System.Net tracing or tools such as Microsoft Network Monitor and Wireshark can help.

Besides, I agree 8% looks bad, mate :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号