tags:

views:

41

answers:

1

I am trying to make Http connections made by C# HttpClient helper class reusable. I read that there is KeepAlive header which has to be present in Http request.

I sniffed the traffic and I cant find any reference to KeepAlive.

It has GET and it has HTTP/1.1 strings in there. No KeepAlive no nothing.

P.S. I also tried to find KeepAlive property somewhere on HttpClient but couldnt...

Any ideas?

+2  A: 

It should have a Connection header, which looks like this:

  • Connection: Close
  • Connection: Keep-Alive

The keep-alive header looks like this:

  • Keep-Alive: 115
Sjoerd
thank you! would you have any suggestion is why this doesnt appear in the fiddler when I call REST service?
Bobb
It could be you are using Fiddler as a proxy and that it removes these headers in the request to the server. In this case, the headers apply to the connection between the client and the proxy, and not between the proxy and the server. This means the proxy should not send them to the server, and maybe it does not even display them. See also http://www.west-wind.com/Weblog/posts/177835.aspx
Sjoerd
@Bobb In Http 1.1 KeepAlive is the default behaviour. See this http://www.io.com/~maus/HttpKeepAlive.html
Darrel Miller
Yeah. I read about however I see 600 TCP connections opened by 20 threads each has only one HttpRequest instance at a time... And I dont see any Connection: Keep-Alive... What I clearly see in every response is: Connection: close..... So how this can be explained? Default behaviour eh?
Bobb
@Sjoerd - the article you suggested is about testing localhost as server which makes Fiddler to be a proxy. I use real remote service. So it is not applicable. But thanks anyway
Bobb