我目前有一个应用程序,调用服务器上的Web服务进行搜索。我们可以期望返回大量数据,因此搜索需要花费超过一分钟的时间是常见的。
对于这样的大容量搜索,我们收到了以下错误消息:
请求通道在等待00:00:59.7350618后等待答复时超时。增加传递给Request调用的超时值或增加Binding的SendTimeout值。分配给此操作的时间可能是较长超时的一部分。
这是我们在已发布的多个问题中看到的内容,不幸的是,所有可用解决方案都没有帮助我解决问题,甚至无法配置超时窗口。
我们已更改客户端的app.config,并增加了所有涉及的超时时间(CloseTimeout,OpenTimeout,ReceiveTimeout和SendTimeout),以及服务器上服务的所有web.config值(closeTimeout,openTimeout和SendTimeout)。
但是这些更改都没有任何效果,我仍然收到一分钟超时。 有什么想法为什么更改这些值没有任何效果?
在下面的示例中,我们缩短了时间,以避免在测试期间必须等待整个分钟。
Web.config:
<configuration>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="TraceFile" />
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="TraceFile" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="TraceFile" type="System.Diagnostics.TextWriterTraceListener"
initializeData="trace.log" />
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
</switches>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="false" logMessagesAtServiceLevel="false"
logMessagesAtTransportLevel="false" />
</diagnostics>
<services>
<service behaviorConfiguration="SearchIndexServiceBehavior" name="SearchIndex.Service">
<endpoint address="" binding="basicHttpBinding" contract="ISearchIndexServices" />
<host>
<timeouts closeTimeout="00:00:10" />
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding closeTimeout="00:00:10" openTimeout="00:00:15" sendTimeout="00:00:20"
receiveTimeout="00:00:25" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SearchIndexServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.transactions>
<defaultSettings timeout="00:05:00" />
</system.transactions>
</configuration>
应用程序配置
<configuration>
<configSections>
</configSections>
<startup>
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISearchIndexServices" closeTimeout="00:00:10" openTimeout="00:00:15" receiveTimeout="00:10:00" sendTimeout="00:00:20" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="5242880"maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://MyServer/SearchIndexService/SearchIndexServices.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISearchIndexServices" contract="WFC.ISearchIndexServices" name="BasicHttpBinding_ISearchIndexServices" />
</client>
</system.serviceModel>
</configuration>