I have sent many http requests in cycle with
WebRequest request = (WebRequest)WebRequest.Create(str);
This line takes about 500ms on my computer
WebResponse response = request.GetResponse();
On other computers on the network: 10-20ms
how to fix this bug? What reasons could there be for other computers on the network completing their request faster?
There is no proxy installed, and the request is to 127.0.0.1:port
.
code for log
String IdHTTPUt_Get(string str) { string res="";
DateTime dt = DateTime.Now;
WriteLog("begin");
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
WebRequest request = (WebRequest)WebRequest.Create(str);
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
request.Credentials = new NetworkCredential(opt_Utor_User,opt_Utor_Password);
request.Method = "GET";
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
request.Proxy = null;
using (WebResponse response = request.GetResponse())
{
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
Stream receiveStream = response.GetResponseStream();
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
StreamReader readStream = new
StreamReader(receiveStream,Encoding.UTF8);
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
res = readStream.ReadToEnd();
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
receiveStream.Close();
readStream.Close();
}
WriteLog((DateTime.Now - dt).ToString()); dt = DateTime.Now;
return res;
}