Hi,
I'm hosting a WebAPI (v1) project on IIS 7.5.
Recently I wanted to perform a small benchmark, so I wrote a simple client that POSTs to the same endpoint 20 times in a row (no parallelism here, just sequential requests).
To my surprise, most runs ended with errors after the first request, sometimes as soon as the second request, sometimes later.
According to my client's System.Net logs, everything is fine until a socket is reused : when this happens, the request is sent to the server, and the server replies by sending a chunk of data without any headers. It's as if IIS saw a socket it already worked
with and thought that it already sent it the headers (note that the previous request that used this socket ended correctly, with an empty chunk to mark the end of the transfer). Of course this headerless response looks completely bogus to my client, which
fails with a "protocol violation" error.
Disabling keep-alive makes the issue disappear (obviously, since it only happens on socket reuse), but I'd like to keep that feature activated.
Sending back a smaller response makes the issue disappear, because in that case IIS does not send a chunked response.
Disabling compression alors makes the problem go away, because in that case IIS does not send a chunked response either.
One thing I also noticed in the logs is that sometimes IIS seems to stop compressing the response right in the middle : my System.Net logs show chunks comprised of what looks like gzipped data, then suddenly switches to plain text for the next chunks... but according to the logs, the request succeeds.
I run my tests on a local dev machine, but running it against a remote server gives the same results. Also, this does not seem resource-related since my local machine does not show heavy CPU or memory usage during the tests.
Any ideas what could be causing this ?