我们在WCF服务中遇到了很多问题,因为它会发出大量的出站请求。我们有挂起的IIS请求,这些请求会不断积累,直到服务器最终宕机。我们得到了堆栈转储,这让我们相信当我们在using语句中调用HttpWebResponse.GetResponse()时,它正在发生,比如下面的代码位。
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
str = reader.ReadToEnd(); //Not Being Hot When Exception Thrown
reader.Close(); //Not Being Hot When Exception Thrown
response.Close(); //Not Being Hit When Exception Thrown
}
}我读到了一些文章,包括“"Do Not Usre 'Using for WCF Clients'”
虽然我没有创建WCF客户端,但我想知道这是否因为它是在我的WCF服务的上下文中而发生的?
例外情况是TimeoutException,因为请求花费的时间超过一分钟。我很清楚我可以更改超时,但我并不是在寻找修复方法。我想知道当这个异常发生时,我是否在消耗连接。
发布于 2013-07-11 05:53:08
不,当对象被释放时,您的连接将关闭。这里不需要调用Close()。
https://stackoverflow.com/questions/17578170
复制相似问题