title: 502 bad gateway eror when multiple parallel http webrequest are spawned to server
body: <p>I am doing stress testing and hence spawned many parallel threads to hit my proxy server with Task.factory but every time after sometime I get 502 bad gateway error.</p>
  
  <p>My code is as below :</p>
  
  <pre><code>for (int i = 0; i &lt; tsk.Length; i++)
  {
      ds = 0;
  
      tsk[i] = Task.Factory.StartNew((object obj) =&gt;
      {
          HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(proxyforDownload);
          request.Method = "GET";
          request.UseDefaultCredentials = false;
          request.PreAuthenticate = true;
          request.Credentials = cc;
          request.Headers.Add("Device", DeviceInf);
          request.Headers.Add("ServerUrl", webdevurl);
          System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();
          HttpWebResponse response = (HttpWebResponse)request.GetResponse();
          watch.Stop();
     }, i);
  }
  </code></pre>
  
  <p>I am getting bad gateway exception after sometime every time I run the code. Where can be issue. </p>