I use this code on a PC and all my webrequest take less than a second but When I run it on my vps with windows server 2008 R2 it extremely slow(took about 40 seconds for one request)
var restClient=new RestClient(new Uri("my web service address"));
var restRequest=new RestRequest();
restRequest.AddParameter("username","xxx" );
restRequest.AddParameter("password","xxx" );
restRequest.AddParameter("msgid",textBox1.Text);
restClient.Proxy = null;
ServicePointManager.Expect100Continue = false;
ServicePointManager.UseNagleAlgorithm = false;
for (int i = 0; i < 10; i++)
{
Task t = Task.Run( () =>
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var response = restClient.Execute(restRequest);
stopwatch.Stop();
Debug.WriteLine(response.Content + " Total time:" + stopwatch.Elapsed);
});
}
I test all options, but nothing helps.