I am creating an application that receives information from a website, this website returns a single line of text with data. To get this, I just use WebClient.DownloadString()
. This is the code:
{
WebClient Client = new WebClient();
Client.Proxy = null;
return Client.DownloadString(url);
}
The problem is that on the first request, this process always accepts ~21.000ms
, and the next - regular intervals. There are similar questions, and pepole seems to solve this problem by adding a line Client.Proxy = null;
, but it does not fix my problem. My proxy settings are disabled, and the firewall does not block anything (I tried to disable it).
I also tested various sites like google (to test it not for a server problem), but the results are the same. I also tried using the control WebBrowser
and HttpWebRequest
, but the results are the same too.
In ordinary browsers (proven edge, firefox and chrome) loading the same page takes about 200ms
with cleared cache.
Using wirehark, I got this, but I don't know how to interpret it:
With firefox:
TCP:
1. SYN (client-server)
2. SYN (client-server)
3. SYN ACK (server-client)
4. ACK (client-server)
5. SYN ACK (server-client)
6. ACK (client-server)
HTTP:
5. GET (client-server)
TCP:
7. ACK (server-client)
HTTP:
5. RESPONSE 200 OK (server-client) (The correct response is received)
TCP:
7. ACK (client server)
Then with my program:
I get the exact same procedure, but the first packet sent over TCP uses IPv6 addresses instead of IPv4, then it waits for 21, and then the rest of the packets, the actual HTTP GET-RESPONSE time is short, as it should be.
source
share