.NET Web 服务 (asmx) 超时问题

发布于 2024-09-06 05:40:59 字数 2090 浏览 0 评论 0原文

我正在连接到供应商提供的 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]

我联系了供应商。他们确认电话可能需要一个多小时(别问,他们是我存在的祸根。)为了安全起见,我将超时时间增加到 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>

相当荒谬,但无论如何超时仍然在 1 小时开始。不幸的是,每个更改都至少需要额外一个小时来测试。我是否遇到了一些内部限制 - 另一个超时设置需要在某处更改?一小时内对这些设置的所有更改都达到了预期效果。

感谢您提供的任何帮助!

I'm connecting to a vendor-supplied web ASMX service and sending a set of data over the wire. My first attempt hit the 1 minute timeout that Visual Studio throws in by default in the app.config file when you add a service reference to a project. I increased it to 10 minutes, another timeout. 1 hour, another timeout:

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]

I contacted the vendor. They confirmed the call may take over an hour (don't ask, they are the bane of my existence.) I increased the timeout to 10 hours to be on the safe side. However the web service call continues to time out at 1 hour. The relevant app.config section now looks like this:

   <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>

Pretty absurd, but regardless the timeout is still kicking in at 1 hour. Unfortunately every change takes at least an additional hour to test. Is there some internal limit that I'm bumping into - another timeout setting to be changed somewhere? All changes to these settings up to one hour had the expected effect.

Thanks for any help you can provide!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故笙诉离歌 2024-09-13 05:40:59

首先:
请参阅 Steven Cheng[MSFT] 回复 这里关于超时。您可以为 httpRuntime 设置执行超时。 ,那就是“此外,请确保您已将‘编译 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)

完成的事件处理程序将有一个特定的事件参数参数,其中将包含结果,对于事件参数e,e.Result在完成时应该有你需要的东西。

Firstly:
See Steven Cheng[MSFT] response here about timeouts. There is a execution timeout you can set for httpRuntime. He says something interesting after that, which is "Also, make sure that you've set the 'compilation debug="false"' as to make the timeout work correctly"

Besides the fact that something may be terribly wrong on their end (or the data returned is so voluminous/ I'm not going to judge - might be a good reason), have you tried calling their operation Asynchronously? Same results? I guess it would take an hour

YourVendor.WebService ws = new YourVendor.WebService();
ws.LongRunningOperationCompleted += new YourVendor.LongRunningOperationEventHandler(ws_LongRunningOperationCompleted);

ws.LongRunningOperationAsync();

// Implement the ws_LongRunningOperationCompleted handler (stub will auto generate)

The completed event handler will have a specific event args param, which will contain the results, for event args e, e.Result should have what you need when it completes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文