如果我使用此代码:
//in this timeout code necessary?
ServiceClient.Timeout = 10;
ServiceClient.GetRestaurantsByNameAsync (MenuFinderApp.RestaurantSearchName);
ServiceClient.GetRestaurantsByNameCompleted += delegate(object sender, GetRestaurantsByNameCompletedEventArgs args) {
//code to show records
};
我返回了几条记录。如果我等待大约 5 - 10 分钟并再次执行代码,我会收到超时错误。为什么会发生这种情况,如何保持连接打开?我必须指定 60 分钟的超时时间吗?这是我的 WCF 服务的 Web.config:
<binding name="BasicHttpBinding_IMenuFinderAppService" closeTimeout="infinite" openTimeout="infinite" receiveTimeout="infinite" sendTimeout="infinite" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="500000" maxBufferPoolSize="524288" maxReceivedMessageSize="500000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="500000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>