title: Why sometimes a very long delay in calling Web API Method
body: <p><strong>Details</strong>: I'm running a VS. WebApi application on an Azure Cloud service. I'm running in a dev environment with debugging on (not sure if that matters). When I execute the web method below, using fiddler, most times the response is very fast - in the order of 200ms complete transaction time. However, on occasion the response is above 1-2 seconds. I'm trying to understand why. For troubleshooting, I'm using both the fiddler diagnostic results as well as a custom header that I place in the response that gives me some time information (X-diagnostics)</p>
  
  <p><strong>Question(s)</strong> : Given the fiddler response below juxtaposed with my custom diagnostics, and given once again that most times my responses are very fast;</p>
  
  <ol>
  <li>Why is there a TCP/IP connect of more than 1000ms?</li>
  <li>Why is there such a delay between fiddler's begin request and the entry to the method (I log start as soon as I enter the method)</li>
  <li>Why is there such a delay between the method exit and fiddler's begin response. </li>
  <li>Why would this happen only on occasion</li>
  <li>Is there anything I can do to prevent it?</li>
  </ol>
  
  <hr>
  
  <p><strong>Web Method</strong></p>
  
  <pre><code>    [Route("api/devicereports")]
      [Route("api/v0/devicereports")]
      [HttpPost]
      public HttpResponseMessage PostStatusReport([FromBody] object report, bool includeDiagnostics = false)
  </code></pre>
  
  <p><strong>Fiddler Response</strong></p>
  
  <pre><code>ClientConnected:      07:18:26.917
  ClientBeginRequest:   07:18:26.918
  GotRequestHeaders:    07:18:26.918
  ClientDoneRequest:    07:18:26.918
  Determine Gateway:    0ms
  DNS Lookup:           0ms
  TCP/IP Connect:       1015ms
  HTTPS Handshake:      0ms
  ServerConnected:      07:18:27.933
  FiddlerBeginRequest:  07:18:27.933
  ServerGotRequest:     07:18:27.933
  ServerBeginResponse:  07:18:30.558
  GotResponseHeaders:   07:18:30.558
  ServerDoneResponse:   07:18:30.558
  ClientBeginResponse:  07:18:30.558
  ClientDoneResponse:   07:18:30.558
  
  **Overall Elapsed:  0:00:03.640**
  </code></pre>
  
  <p><strong>My Custom Diagnostics</strong></p>
  
  <pre><code>X-Diagnostics: Start=14:18:29.885 &amp;&amp; Finish=14:18:30.025 &amp;&amp; Time(ms)=140  &amp;&amp; Leave=14:18:30.025
  </code></pre>
  
  <p><strong>Analysis</strong></p>
  
  <pre><code>FIDDLER: RequestBegin;  27.933
  CODE   : Start;         29.885
  CODE   : Finish;        30.025
  FIDDLER: BeginResponse; 30.558
  </code></pre>