我已经自行托管了一个 WCF 服务,BasicHttpBinding
而ASMX Client
. 我正在模拟1200个用户的并发用户负载。service 方法接受一个字符串参数并返回一个字符串。交换的数据小于10KB。使用 Thread.Sleep(2000) 语句将请求的处理时间固定为 2 秒。没有额外的东西。我已经删除了所有的 DB Hits / 业务逻辑。
同一段代码对 1000 个并发用户运行良好。当我将数量增加到 1200 个用户时,我收到以下错误。
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at WCF.Throttling.Client.Service.Function2(String param)
此异常通常在 DataContract 不匹配和大型数据交换时报告。但是在进行负载测试时永远不会。我已经浏览了足够多的内容并尝试了大多数选项,其中包括,
- 在服务器端启用跟踪和消息日志。但没有记录错误。
- 为了克服端口耗尽,MaxUserPort 设置为 65535,TcpTimedWaitDelay 设置为 30 秒。
- MaxConcurrent Calls 设置为 600,MaxConcurrentInstances 设置为 1200。
- 打开、关闭、发送和接收超时设置为 10 分钟。
- HTTPWebRequest KeepAlive 设置为 false。
在过去的两天里,我一直无法确定这个问题。
任何帮助,将不胜感激。
谢谢你。