发生 WebClientProtocol 超时时会发生什么

发布于 2024-07-11 08:27:10 字数 250 浏览 6 评论 0原文

我们有一个引用 Web 服务的客户端应用程序。 我们已将 webclientprotocol 对象的超时属性设置为 50(毫秒),并希望观察发生了什么。 我们绑定了一个长时间运行的 Web 方法,该方法向客户端返回一个巨大的数据集。 当默认值存在时,DataSet 会正确返回给客户端。 当我们将其更改为 50(ms) 时,我们没有观察到任何情况。 我们的假设是,由于发生超时,客户端会发生某种异常。 谁能解释一下这里发生了什么

谢谢 拉杰

We have a client application that has reference to a webservice. We had set the timeout property on the webclientprotocol object to 50 (ms) and wanted to observe what goes on. We tied up a long running webmethod that returns a huge DataSet to the client. When the default value was there, the DataSet was returned properly to the client. When we changed this to 50(ms), we did not observe anything. Our assumption was that there would be some kind of exception that occurs on the client side since the timeout has occurred. Can anyone please explain what is going on here

Thanks
Raj

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

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

发布评论

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

评论(2

南烟 2024-07-18 08:27:10

不幸的是,该文档不清楚。 当你说“没有观察到任何东西”时,你到底是什么意思? 代码会永远挂起吗? 是否抛出异常? 推测未返回有效的数据集。

期望一个TimeoutException被抛出,但令我惊讶的是,这在您的客户端代码中并不完全明显。 你没有接受例外,是吗?

您是同步执行调用还是异步执行调用? 如果它是异步的,我希望执行回调,然后在“EndXxx”调用上抛出异常。

我强烈建议您编写一个简短的控制台应用程序,它只是调用 Web 服务,只是为了看看会发生什么。

The documentation is unfortunately unclear. When you say you "didn't observe anything" what exactly do you mean? Did the code hang forever? Was an exception thrown? Presumaby a valid DataSet wasn't returned.

I would expect a TimeoutException to be thrown but I'm surprised that wasn't entirely obvious in your client code. You're not swallowing exceptions, are you?

Are you executing the call synchronously or asynchronously? If it's asynchronous, I'd expect the callback to be executed and then the exception to be thrown on the "EndXxx" call.

I strongly recommend that you write a short console application which just calls the web service, just to see what happens.

睫毛上残留的泪 2024-07-18 08:27:10

我刚刚遇到了这个。 在 .NET 2.0 Web 服务中,它会抛出一个非常不具体的 WebException,只有 Message 属性来区分它:

请求被中止:连接意外关闭。

我还没有在较新版本的 Visual Studio 中默认生成的基于 WCF 的服务引用中尝试过它,但如果我理解 this 正确的话,它们会抛出一个更有用的 TimeoutException,就像 Jon Skeet,我猜测(并且更愿意)是 Web 服务中的行为。

请注意,超时仅适用于同步调用(至少在 Web 服务中;我认为对于 WCF 服务引用也是如此)。 如果您希望异步调用超时,则必须设置计时器并手动中止调用,如演示的 此处

I just ran into this. In a .NET 2.0 Web service, it throws a pretty unspecific WebException, with only the Message property to distinguish it:

The request was aborted: The connection was closed unexpectedly.

I haven't tried it in the WCF-based service references generated by default in newer versions of Visual Studio, but if I understand this correctly, they throw a more useful TimeoutException, which, like Jon Skeet, I would have guessed (and would prefer) to be the behavior in a Web service.

Note that the timeout is only for synchronous calls (at least in a Web service; I think it's true for a WCF service reference, too). If you want an asynchronous call to time out, you'll have to set a timer and abort the call manually, such as demonstrated here.

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