Web请求从不超时 [英] web calls never timing out

查看:194
本文介绍了Web请求从不超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些使用各种网络技术,如SOAP,WCF服务,或者只是简单的XmlReader应用。不过,他们似乎都遭受缺少超时和挂无限,如果互联网连接遭受在错误的时间问题,同样的问题。

I have a number of applications using various web technologies such as SOAP, WCF Services, or just simple XmlReader. However they all seem to suffer the same problem of missing the timeout and hanging infinitely if the internet connection suffers problems at the wrong time.

我已经设置了超时的所有场景到小东西,例如:为WCF

I have set the timeout in all scenarios to something small, e.g. for wcf

closeTimeout="00:00:15" openTimeout="00:00:15" 
receiveTimeout="00:00:15" sendTimeout="00:00:15"

或肥皂

_Session.Timeout = (int)TIMEOUT.TotalMilliseconds;



这些超时也普遍被击中,但它似乎没有,如果互联网滴出,其中一些特殊的情况下,在正确的时间,通话将挂起和(使用同步调用)永不超时。

These timeouts do generally get hit, however it appears there is some special case where if the internet drops out at the right time, the call will hang and never time out (using synchronous calls).

我在考虑我每次拨打电话时启动一个定时器,并用相应的 .Abort()如果计时器到期取消呼叫功能。不过,我想知道是否有解决的问题,并确保超时被打了一个简单的方法。

I was considering starting up a timer every time I make a call, and using the appropriate .Abort() function if the timer expires to cancel the call. However, I was wondering if there was a simpler way to fix the issue and ensure the timeout gets hit.

有谁知道为什么发生这种情况,如果是什么干净/简单/好办法是始终确保调用超时?

Does anyone know why this occurs, and if so what a clean/simple/good way is to ensure the calls always time out?

推荐答案

我可以的为什么它发生,但没有给出一个解决方案:(

I can guess at why it occurs, but without giving a solution :(

我的犯罪嫌疑人的它陷入了DNS解析我见过的各种情况下。认为不计 - 它最终发生的异步调用,或者它绝对不会被列入超时的启动线程如

I suspect it's getting caught up on DNS resolution. I've seen various situations where that "doesn't count" - e.g. where it ends up happening on the initiating thread of an asynchronous call, or where it's definitely not been included in timeouts.

如果您能够再拉出你的网线重现此,我建议使用Wireshark来证实我的猜测 - 这至少会建议进行调查更多的渠道,也许有在.NET堆栈某处DNS超时这通常是无限的,但它可以进行调整,例如。

If you're able to reproduce this by pulling out your network cable, I'd suggest using Wireshark to confirm my guess - that would at least suggest further avenues for investigation. Maybe there's a DNS timeout somewhere in the .NET stack which is normally infinite but which can be tweaked, for example.

这篇关于Web请求从不超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆