问题描述
这似乎是一个愚蠢的问题,但 WCF 中的所有内容似乎都比 asmx 复杂得多,如何增加 svc 服务的超时时间?
Might seem like a silly question, but everything in WCF seems a lot more complicated than in asmx, how can I increase the timeout of an svc service?
这是我目前所拥有的:
<bindings>
<basicHttpBinding>
<binding name="IncreasedTimeout"
openTimeout="12:00:00"
receiveTimeout="12:00:00" closeTimeout="12:00:00"
sendTimeout="12:00:00">
</binding>
</basicHttpBinding>
</bindings>
然后我的端点被映射成这样:
And then my endpoint gets mapped like this:
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="IncreasedTimeout"
contract="ServiceLibrary.IDownloads">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
我得到的确切错误:
请求通道在 00:00:59.9990000 之后等待回复时超时.增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值.分配给此操作的时间可能是较长超时的一部分.
The request channel timed out while waiting for a reply after 00:00:59.9990000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
在 WCF 测试客户端中,有一个配置图标,其中包含我的服务的运行时配置:
In the WCF Test Client, there is a config icon that contains the run time configuration of my service:
如您所见,它的值与我为它设置的值不一样?我做错了什么?
As you can see its not the same values as I've set for it? What am I doing wrong?
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDownloads" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
推荐答案
超时配置需要在客户端设置,所以我在web.config里设置的配置没有效果,WCF测试工具有自己的配置,还有你需要设置超时的地方.
The timeout configuration needs to be set at the client level, so the configuration I was setting in the web.config had no effect, the WCF test tool has its own configuration and there is where you need to set the timeout.
这篇关于WCF 服务,如何增加超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!