2

I have a question about HttpClient. I use it like this

HttpClient client = new HttpClient(MyHandler, false);

I use WebRequest.GetSystemproxy() for the handler

At some point, it lose the connection with the server and raise exceptions (taskcancel , it seems to be timeout, I don't have more explicite log at this time).

The only solution i have is to do a new httpClient, after that it works well for a new period.

I don't understand why?

in http 1.1, connexion can be close by server when it wants or needs. If server close connexion will httpclient initialize a new one? or it's just the "why" I have this problem?

I read that httclient can be reused (here and elsewhere) and it designed for that but it's not what I see in my case. After some httprequests, I can't reuse it.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Raphael
  • 21
  • 2
  • Why not just create a new `HttpClient` object for every request? That way you can wrap that in your exception checking routines and handle it all gracefully. – DavidG Jun 12 '15 at 08:40
  • 1
    there's a lot fo request et and i try to find the better solution, new httpclient need to connect each time. but best seems to be the ennemy of good here. Also, i try to understand our this damned class work. – Raphael Jun 12 '15 at 13:26

0 Answers0