我在IIS 7(Windows Server 2008)上运行WCF 4服务,部署到开发服务器。当我运行一个使用该服务的小型网站时,该服务正常工作(单击一个按钮,页面调用该服务,返回数据。这是非常基本的。)
我还创建了一些调用服务的单元测试,并将它们放入负载测试中。简而言之,“单元测试”调用服务并将从服务流回的byte[]
写入文件。运行负载测试时,该服务按预期执行。
问题是在极少数迭代后负载测试失败。有时福音呼叫是成功的,有时是在五次呼叫之后。同样,单独地,测试运行正常,但是当我将它们组合在一起以模拟实时环境(多个用户,多个测试迭代)时,会出现此问题。
抛出的异常是:
Test method TestProject1.UnitTest1.RunReport threw exception:
System.ServiceModel.CommunicationException:
An error occurred while receiving the HTTP response to http://xx.xx.xx.xx:yy/Service.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> 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
更新#1: 我只是将测试迭代设置为10(运行测试10x)并将常量用户负载设置为1.测试能够成功完成。这是使用最基本的单元测试。第二次更复杂的测试被省略了。
答案 0 :(得分:1)
查看应用程序事件日志(eventvwr.exe)。假设您在大多数正常环境中运行,则会出现服务器端错误的条目。