【发布时间】:2012-06-08 06:06:38
【问题描述】:
我正在创建一个 WCF 服务器-客户端应用程序。然而,在我的第一个测试中,一个简单的调用(该方法基本上只是return true;)需要很多时间(~5 秒)
我试图追踪它,这是呼叫追踪的截图
如您所见,第 2 行和第 3 行之间有 5 秒的间隔(虽然说实话我不知道第 2 行和第 3 行是什么意思)
在客户端(调用者)的配置下,绑定是这样的(多为Visual Studio生成的
<wsHttpBinding>
<binding name="WSHttpBinding_IAgent" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
</security>
</binding>
</wsHttpBinding>
在服务器上
<wsHttpBinding>
<binding name="WSHttpBinding_IAgent" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:05:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="16777216" maxReceivedMessageSize="16777216"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="16777216"
maxArrayLength="16384" maxBytesPerRead="16384" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None"/>
</binding>
我这样称呼它的方式
var client = new AgentClient(binding, BuildEndpointAddress(hostName, port));
for(int i =0; i<10; i++)
client.IsAlive(); //this call is very slow despite just returning true;
// subsequent calls are also slow so probably not because of wake-up time
此测试请注意,服务器和客户端都在同一台计算机上,因此不会是网络问题。知道是什么导致了缓慢或如何找到更多信息来解决此问题吗?
【问题讨论】:
-
后续调用是否更快?可能在第一次调用时正在编译或“唤醒”。
-
不,我尝试循环调用 client.IsAlive() 几次,随后的调用与第一次没有区别。
-
@dbaseman 确切地说,持续时间确实有所不同,但似乎是因为随机性而不是系统性。例如,在我的第一个测试中,连续调用的持续时间(相同的方法)是 4 秒、4、6、2、4、3、8,当我重试时是:9、3、2、4、5、5 , 3
-
您是否没有使用同一台计算机进行此测试?这是一篇文章的链接,该文章讨论了在 localhost 上运行时的 5 秒延迟:support.microsoft.com/kb/2020447 不幸的是,它提到了场景中的大量数据(> 64KB)。
-
@RichardMorgan 我现在刚刚尝试过,使用不同的计算机也没有改善它。也没有将主机名更改为 IP 地址
标签: .net wcf debugging soap wshttpbinding