Steve B
Steve B

Reputation: 37660

Slow WebClient.DownloadString?

I'm working on a web application that runs with ASP.Net 3.5

Somewhere in the application, I'm making calls to an external system. This call consists on downloading a string from a specific url :

string targetUrl = BuildMyUrl();
WebClient wc = new WebClient();
string data = wc.DownloadString(targetUrl);

This code works quite well with a acceptable response time (under 500ms).

However, in specific cases this response time is over 15 seconds. I can reproduce the behavior, and I can clearly see the long time is on the DownloadString call.

I don't understand why this occurs in my scenario.

You will say : "Hey, it's the target system that is slow". But I was not able able to reproduce the behavior outside my application (I've build a small console application that isolate the faulting code. Never get any issue).

I don't know where to look now to understand the issue. What can cause a simple download data to be be lengthy ?

FYI: the target system is an authentication service. The target url is of kind :

httpS://mysystem/validate?ticket=XXXYYY

Maybe the https protocol is the issue.

Does using WebClient class under IIS can alter the behavior of the WebClient ?

[Edit] I've tried :

None of this test were successful.

Upvotes: 3

Views: 1902

Answers (2)

Steve B
Steve B

Reputation: 37660

The latency was due to a certificate validation timeout. One of the issuer in the chain was not correctly deployed in the client server.

Upvotes: 0

Anton Berlinsky
Anton Berlinsky

Reputation: 615

Try to use Fiddler or some integrated network analyzer inside Chrome/FF browsers to see the HTTPS requests/responses and their headers.

Upvotes: 0

Related Questions