C#Web引用叫暂停 [英] C# Web Reference Call Timeout

查看:149
本文介绍了C#Web引用叫暂停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的Web引用外部服务的调用。该IP的是动态的,所以我打电话给他们一个接一个,和一切工作正常。定期一些IP的将不可用,我得到一个超时而我处理。问题是它需要超时时间长度是每个通话30秒左右。我试图改变在WS超时属性为5秒,但它似乎不有所作为。是否有人可以帮助我这个

I am making a call to an external service using a web reference. The IP's are dynamic so I call them one by one, and everything works fine. Periodically some of the IP's won't be available and I am getting a timeout which I am handling. The issue is the length of time it takes to timeout is around 30 seconds for each call. I tried changing the timeout property on the ws to 5 seconds but it doesn't seem to make a difference. Can someone please help me with this?

推荐答案

下面就是我一直在寻找的答案:
http://stackoverflow.com/questions/1500955/adjusting-httpwebrequest-connection-timeout-in-c\">Adjusting HttpWebRequest的连接超时

Here is the answer I was looking for: Adjusting HttpWebRequest Connection Timeout in C#

* 重要片段:的*

*Important Snippet:*

从MSDN文档的 HttpWebRequest.Timeout 属性:

From the MSDN documentation of the HttpWebRequest.Timeout property:

一个域名系统(DNS)查询可能需要长达 15 秒返回或时间
OUT。如果您的请求包含需要解析主机名和你设置超时的值小于15秒,可能需要15秒以上引发WebException,表示你的请求超时之前。

A Domain Name System (DNS) query may take up to 15 seconds to return or time out. If your request contains a host name that requires resolution and you set Timeout to a value less than 15 seconds, it may take 15 seconds or more before a WebException is thrown to indicate a timeout on your request.

这篇关于C#Web引用叫暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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