Search code examples
asp.netxmlhttprequestfiddler

Simulate latency between packets for HTTP POST requests with Fiddler


I can see how I can script an overall latency in Fiddler using the ScriptEditor, using something like this:

if (oSession.HostnameIs("www.testsite.co.uk")) {
    oSession["request-trickle-delay"] = "500";
}

However, I need to be more specific and specify a delay between the first packet of the request which contains the header, and the secondary packets that contain the body.

I am trying to simulate a problem that is occurring with 0.3% of our web clients, from whom we are receiving a request header, but a missing request body. There is no consistent user agent. Various browsers and operating systems appear to be affected. All POST requests are originating from XMLHttpRequests (XHR). They look like this, and contain JSON bodies:

POST http://www.sitename.co.uk/folder/controller/list HTTP/1.1
Host: www.sitename.co.uk
Connection: keep-alive
Content-Length: 245
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://www.sitename.co.uk
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
Content-Type: application/json
Referer: http://www.sitename.co.uk/folder/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en;q=0.8,en-US;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: **removed**

{"bb":{"tl":{"lat":51.590527931951975,"lng":-0.636399852539089},"tr":{"lat":51.590527931951975,"lng":0.42652739355466096},"bl":{"lat":51.29736817638294,"lng":-0.636399852539089},"br":{"lat":51.29736817638294,"lng":0.42652739355466096}},"b":true}

I have checked the MTU size set at firewall level and it is set to 1500, which I believe to be fine.

The web servers are behind a load balancer and are running IIS 7.5 on Windows Server 2008 R2 64-bit. Website is running on ASP.NET MVC3.


Solution

  • It's worth mentioning that headers may be in more than one TCP/IP packet, and there's nothing that requires that the body be in a different packet than the headers. But I assume you're using the term packet loosely

    Fiddler v2.4.2.6 has a Request-Body-Delay session flag that would enable the delay you're looking for; set it to e.g. 5000 to delay the body by 5 seconds. (v2.4.2.6 is currently in alpha: https://fiddler2.com/dl/fiddler2alphasetup.exe)

    FWIW, it's possible that the headers were sent but the POST body wasn't. That can happen in IE if you have a buggy plugin installed (see Why is IE 10 Refusing to send POST data via jQuery $.ajax for an example).

    This problem can also occur if the connection is dropped. For instance, if you are attempting to do a POST in the OnBeforeUnload method, the headers may be sent but the process killed before the POST body is emitted.