我使用以下代码来调查未能关闭代理时会发生什么:
class Program
{
static void Main()
{
for (int i = 1; i < 500; i++)
{
MakeTheCall(i);
}
Console.WriteLine("DONE");
Console.ReadKey();
}
private static void MakeTheCall(int i)
{
Console.Write("Call {0} - ", i);
var proxy = new ServiceReference1.TestServiceClient();
var result = proxy.LookUpCustomer("123456", new DateTime(1986, 1, 1));
Console.WriteLine(result.Email);
//proxy.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
该服务使用net.Tcp绑定,WAS托管,所有默认值.
运行它,当我> 400时我得到超时.为什么400 - 这是一个设置somwhere?我预计它会少得多 - 等于maxConnections.
通过不关闭代理,您将维护服务的会话.maxConcurrentSessions限制属性控制服务可以容纳的会话数.默认(在.NET 4.0中)是100*Processor Count,所以我猜你有4个处理器(或核心)= 400个并发会话?