title: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed
body: <p>I am having an issue :</p>
  
  <blockquote>
    <p>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond URL.</p>
  </blockquote>
  
  <p>Also I get issue like: </p>
  
  <blockquote>
    <p>System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>System.Net.WebException: The operation has timed out at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)</p>
  </blockquote>
  
  <p>I know that this question has asked before but believe me I tried almost every single resolution at my end.</p>
  
  <p>Weird thing is this issue does not appear at my end at all and only when client try to use which is not constant. Some time my application works fine at their end too.</p>
  
  <p>What I am trying to accomplish is I have created an desktop application (Win Forms &amp; C#) and trying to login client while sending request to my php api server which is hosted on GODaddy.</p>
  
  <pre><code>var request = (HttpWebRequest)WebRequest.Create("url");
  if (request != null)
  {
      #region System.Net.WebException
      request.Method = "POST";
      if (!string.IsNullOrEmpty(body))
      {
          var requestBody = Encoding.UTF8.GetBytes(body);
          request.ContentLength = requestBody.Length;
          request.ContentType = "application/json";
          using (var requestStream = request.GetRequestStream())
          {
              requestStream.Write(requestBody, 0, requestBody.Length);
          }
      }
      else
      {
          request.ContentLength = 0;
      }
      request.Timeout = 15000;
      request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
  
      string output = string.Empty;
      try
      {
          using (var response = (HttpWebResponse)request.GetResponse())
          {
              using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
              {
                  if (response.StatusCode == HttpStatusCode.OK)
                  {
                      while (!stream.EndOfStream)
                      {
                          output += stream.ReadLine();
                      }
                      output = stream.ReadToEnd();
                  }
              }
          }
      }
      catch
      {
          // Excaption Caught here
      }
  }
  </code></pre>
  
  <p>Please help me out.</p>
  
  <p>Thanks in advance.</p>