Jam*_*Orr 5 .net wcf web-services timeout wcf-client
我正在连接供应商提供的Web ASMX服务并通过网络发送一组数据.当您向项目添加服务引用时,我的第一次尝试达到了默认情况下Visual Studio在app.config文件中引发的1分钟超时.我把它增加到10分钟,另一次超时.1小时,另一个超时:
Error: System.TimeoutException: The request channel timed out while waiting for
a reply after 00:59:59.6874880. 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. ---> System.TimeoutE
xception: The HTTP request to 'http://servername/servicename.asmx' has exceeded the allotted timeout of 01:00:00. The time allotted to this
operation may have been a portion of a longer timeout. ---> System.Net.WebExcept
ion: The operation has timed out
at System.Net.HttpWebRequest.GetResponse() [... lengthly stacktrace follows]
Run Code Online (Sandbox Code Playgroud)
我联系了供应商.他们证实这个电话可能需要一个多小时(不要问,他们是我存在的祸根.)我把超时时间延长到了10个小时以保证安全.但是,Web服务调用将在1小时后继续超时.相关的app.config部分现在看起来像这样:
<basicHttpBinding>
<binding name="BindingName" closeTimeout="10:00:00"
openTimeout="10:00:00" receiveTimeout="10:00:00" sendTimeout="10:00:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)
非常荒谬,但无论超时还是在1小时内踢.不幸的是,每次更改都需要至少一小时的时间来测试.我是否有一些内部限制 - 另一个超时设置要在某处更改?对这些设置的所有更改长达一小时都会产生预期的效果.
感谢您的任何帮助,您可以提供!
首先:请参阅 Steven Cheng[MSFT]此处有关超时的回复。您可以为 httpRuntime 设置执行超时。之后他说了一些有趣的话,那就是“此外,请确保您已设置‘compilation debug="false"’以使超时正常工作”
除了他们的末端可能出现严重错误(或者返回的数据如此庞大/我不会判断 - 可能是一个很好的理由)这一事实之外,您是否尝试过异步调用他们的操作?结果一样吗?我猜需要一个小时
YourVendor.WebService ws = new YourVendor.WebService();
ws.LongRunningOperationCompleted += new YourVendor.LongRunningOperationEventHandler(ws_LongRunningOperationCompleted);
ws.LongRunningOperationAsync();
// Implement the ws_LongRunningOperationCompleted handler (stub will auto generate)
Run Code Online (Sandbox Code Playgroud)
完成的事件处理程序将有一个特定的事件参数参数,其中将包含结果,对于事件参数 e,e.Result 应该在完成时包含您需要的内容。