1

I am trying to use HttpClient via a proxy:

var httpClientHandler = new HttpClientHandler {UseProxy = true, Proxy = new WebProxy("xxx.xxx.xxx.xxx:6762")};
var httpClient = new HttpClient(httpClientHandler) {Timeout = TimeSpan.FromSeconds(3)};

With the 3 second timeout defined in the code, requests sent via this httpClient time out. Through experimentation, I have found that I need to set the timeout to at least 30 seconds for the requests to complete. So you'd think the proxy is just being slow, right?

EXCEPT: if I run Fiddler locally and set the httpClientHandler to use "localhost:8888" (Fiddler's port) and then in turn chain Fiddler to use THE SAME proxy upstream (like in picture below), the requests come back nearly instantaneously.

What could explain such behavior?

Fiddler upstream proxy configuration

EDIT: I should also mention that the requests I am making while seeing this behavior are all HTTPS. I know Fiddler inserts its own certificate into the certificate path, so maybe that is somehow part of the explanation, but I am not knowledgeable enough to put all the pieces together.

July.Tech
  • 1,336
  • 16
  • 20
  • Is the requested URL HTTP or HTTPS? May be the external Proxy is a bit outdated and does not allow current security protocols like TLS 1.2? Fiddler however by default allows SSLv3 with SSL decryption enabled. – Robert Mar 17 '17 at 16:03
  • Yeah, I just made an edit a few minutes before you posted your comments clarifying that I am making HTTPS requests -- I had a hunch that it is somehow related. Your explanation provides a little bit more of a clue. So why would an older protocol be slower? – July.Tech Mar 17 '17 at 16:14
  • 1
    Slower? You wrote there is a time-out and time-out means it does not work at all. In total you should just use Wireshark and monitor the outgoing traffic to the proxy. Then you should see the difference. – Robert Mar 17 '17 at 16:31
  • I probably should've phrased it better. What I was trying to say that with the 3 second timeout setting on the httpclient it times out, so I have to bump it up to 30 in order to get the response. When going through Fiddler the response comes back instantaneously. – July.Tech Mar 17 '17 at 16:35
  • 1
    As I wrote: use wireshark and look if there are differences regarding the SSL/TLS handshake and if you can detect anything when the delay occurs. – Robert Mar 17 '17 at 16:47
  • Thanks, will try that. – July.Tech Mar 17 '17 at 17:03
  • 1
    What does your HTTP request code look like? See http://www.telerik.com/blogs/help!-running-fiddler-fixes-my-app- for one explanation of a problem we've seen. – EricLaw Mar 29 '17 at 16:40
  • An extremely helpful link, Eric! If you'd like to post it as an answer rather than comment, I will mark is as accepted. Thank you! – July.Tech Mar 29 '17 at 19:57

0 Answers0