How to diagnose an "operation timeout" HttpException

I call 5 external servers to retrieve XML-based data for each request for a specific web page on my IIS 6 server. The current volume is 3-5 incoming requests per second, which means 15-20 outgoing requests per second.

99% of outgoing requests from my server (client) to external servers (server) work fine, but about 100-200 a day ends with the exception "Operation is excluded".

This suggests that I have a problem with resources on my server - some lack of sockets, ports, etc. or thread blocking, but the problem with this theory is that the failures are completely random - there are not so many requests in the line, all the failures - and two of the external servers account for most of the failures.

My question is, how can I further diagnose these exceptions to determine if the problem is on my end (client) or on the other end (servers)?

The volume of requests does not allow placing the analyzer on a wire - it would be very difficult to fix these few exceptions. I have reset CONNECTIONS AND THREADS in my machine.config, and the base code is as follows:

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

Any suggestions?

+3
source share
2 answers

You said that you make 5 outgoing requests for every incoming request to an ASP page. Is it 5 different servers or the same server?

, , ? -, /?

- /, , . , , - wirehark/netmon , , , .

, windbg.exe w3wp.exe, . sos.dll. ! Threads, ! Threadpool command. , /. #completionport , .

, ASP.NET System.net. ., ASP.NET - , .

, . , . , windbg.exe w3wp, - , .

0

HttpWebRequest HTTP/1.1. , , , , , -.

ServicePointManager.

ServicePointManager.DefaultConnectionLimit = 20 // or some big value.
+2

Source: https://habr.com/ru/post/1736354/


All Articles