我调用5个外部服务器为我的IIS 6服务器上的特定网页的每个请求检索基于XML的数据。目前的数据量在每秒3-5个传入请求之间,这意味着每秒传出15-20个请求。如何诊断“操作超时”HttpException
99%的从我的服务器(客户端)到外部服务器(服务器)的传出请求工作正常,但每天大约100-200次以“操作超时”异常结束。
这表明我在我的服务器上有一个资源问题 - 一些短缺的套接字,端口等或一个线程锁,但这个理论的问题是,失败是完全随机的 - 在一行中没有数量的请求所有这些都失败了 - 两台外部服务器解决了大部分故障。
我的问题是如何进一步诊断这些异常以确定问题是在我的端(客户端)还是在另一端(服务器)?
请求的数量排除了将分析仪放在电线上 - 捕获这些少数例外将是非常困难的。我在我的machine.config中重置了CONNECTIONS和THREADS,基本代码如下所示:
Dim hRequest As HttpWebRequest
Dim responseTime As String
Dim objWatch As New Stopwatch
Try
' calculate time it takes to process transaction
objWatch.Start()
hRequest = System.Net.WebRequest.Create(url)
' set some defaults
hRequest.Timeout = 5000
hRequest.ReadWriteTimeout = 10000
hRequest.KeepAlive = False ' to prevent open HTTP connection leak
hRequest.SendChunked = False
hRequest.AllowAutoRedirect = True
hRequest.MaximumAutomaticRedirections = 3
hRequest.Accept = "text/xml"
hRequest.Proxy = Nothing 'do not waste time searching for a proxy
hRequest.ServicePoint.Expect100Continue = False
Dim feed As New XDocument()
' use *Using* to auto close connections
Using hResponse As HttpWebResponse = DirectCast(hRequest.GetResponse(), HttpWebResponse)
Using reader As XmlReader = XmlReader.Create(hResponse.GetResponseStream())
feed = XDocument.Load(reader)
reader.Close()
End Using
hResponse.Close()
End Using
objWatch.Stop()
' Work here with returned contents in "feed" document
Return XXX' some results here
Catch ex As Exception
objWatch.Stop()
hRequest.Abort()
Return Nothing
End Try
有什么建议吗?
传出的请求(以及针对该事件的传入)都在一个具有一个IP地址(以太网10meg)的服务器上。现在只尝试尝试同步,因为我想在转换为异步之前确保代码正常工作。 asp.net - >请求排队计数器很少非零,所以不会导致任何地方。请求量确实限制了调试器或wireshark工具的使用。在平均每天超过1M次的请求中发现100个每日超时之一是艰难的。非常感谢您的评论。 – dalej 2010-03-31 15:56:57
这并不难 - 只要将windbg.exe附加到W3WP进程,当您开始获取超时异常,转储进程(.dump/ma <文件名)并分离调试器。然后您可以重新启动调试器,加载之前创建的转储,然后调试... – feroze 2010-04-01 23:09:06