title: Timeout exception on FTP web request after FTP service is restored
body: <p>I get the following exception when calling out to a third party FTP server</p>
  
  <blockquote>
    <p>System.Net.WebException The operation has timed out. - at System.Net.FtpWebRequest.GetResponse()</p>
  </blockquote>
  
  <p>We have asked the third party what are they doing that cause this and they have said <em>"FTP server was unavailable at the firewall level"</em></p>
  
  <p>The following is our code:</p>
  
  <pre><code>var _request = (FtpWebRequest)WebRequest.Create(configuration.Url);
  _request.Method = WebRequestMethods.Ftp.DownloadFile;
  _request.KeepAlive = false;
  _request.Timeout = configuration.RequestTimeoutInMilliseconds;
  _request.Proxy = null;  // Do NOT use a proxy
  _request.Credentials = new NetworkCredential(configuration.UserName, configuration.Password);
  
  _request.ServicePoint.ConnectionLeaseTimeout = configuration.RequestTimeoutInMilliseconds;
  _request.ServicePoint.MaxIdleTime = configuration.RequestTimeoutInMilliseconds;
  
  try
  {
      using (var _response = (FtpWebResponse)_request.GetResponse())
      using (var _responseStream = _response.GetResponseStream())
      using (var _streamReader = new StreamReader(_responseStream))
      {
          this.c_rateSourceData = _streamReader.ReadToEnd();
      }
  }
  catch (Exception genericException)
  {
      throw genericException;
  }
  finally
  {
     _request.Abort();
  }
  </code></pre>
  
  <p>Our application is a windows service and all resources are getting disposed and even the FtpWebRequest is aborted.</p>
  
  <p>We are calling out to third party every hour and as they do maintenance work and make "FTP server was unavailable at the firewall level" we can no longer call out. we get timeout exception.
  This occurs even when third party service is available again.</p>
  
  <p>Only solution is to restart windows service to be able to call out again successfully.</p>
  
  <p>Any ideas on this?</p>