ftpWebResponse fails on alternate calls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeremy

    ftpWebResponse fails on alternate calls

    I'm getting a list of files from an ftp site using the following method. On
    the first call this works perfectly. On the 2nd call, it fails with the
    following error. On the 3rd call it succeeds again.

    "Failed to list incoming files from ftp site The remote server returned an
    error: (550) File unavailable (e.g., file not found, no access)."

    I'm guessing that the ftp server thinks the ftpUserID is already connected,
    but I don't see any way to disconnect. Any suggestions?

    - Jeremy

    internal void listFiles(List< stringincomingF iles)
    {
    FtpWebRequest request =
    (FtpWebRequest) WebRequest.Crea te(ftpPath);
    request.UsePass ive = false;
    request.Method = WebRequestMetho ds.Ftp.ListDire ctory;
    request.Credent ials = new NetworkCredenti al(ftpUserID,
    ftpPassword);
    try
    {
    FtpWebResponse response =
    (FtpWebResponse )request.GetRes ponse(); <== FAILS HERE.
    Stream responseStream = response.GetRes ponseStream();
    StreamReader reader = new StreamReader(re sponseStream);

    incomingFiles.C lear();
    string file = reader.ReadLine ();
    while (file != null)
    {
    incomingFiles.A dd(file);
    file = reader.ReadLine ();
    }
    reader.Close();
    responseStream. Close();//jhg 06/16/2008
    response.Close( ); //jhg 06/16/2008
    }
    catch (Exception ex)
    {
    onProgressEvent Args args = new onProgressEvent Args("Failed
    to list incoming files from ftp site " + ex.Message);
    showProgress(th is, args);
    }
    }

  • parez

    #2
    Re: ftpWebResponse fails on alternate calls

    On Jun 16, 2:14 pm, "Jeremy" <jeremy-nos...@ninproda ta.comwrote:
    I'm getting a list of files from an ftp site using the following method. On
    the first call this works perfectly. On the 2nd call, it fails with the
    following error. On the 3rd call it succeeds again.
    >
    "Failed to list incoming files from ftp site The remote server returned an
    error: (550) File unavailable (e.g., file not found, no access)."
    >
    I'm guessing that the ftp server thinks the ftpUserID is already connected,
    but I don't see any way to disconnect. Any suggestions?
    >
    - Jeremy
    >
    internal void listFiles(List< stringincomingF iles)
    {
    FtpWebRequest request =
    (FtpWebRequest) WebRequest.Crea te(ftpPath);
    request.UsePass ive = false;
    request.Method = WebRequestMetho ds.Ftp.ListDire ctory;
    request.Credent ials = new NetworkCredenti al(ftpUserID,
    ftpPassword);
    try
    {
    FtpWebResponse response =
    (FtpWebResponse )request.GetRes ponse(); <== FAILS HERE.
    Stream responseStream = response.GetRes ponseStream();
    StreamReader reader = new StreamReader(re sponseStream);
    >
    incomingFiles.C lear();
    string file = reader.ReadLine ();
    while (file != null)
    {
    incomingFiles.A dd(file);
    file = reader.ReadLine ();
    }
    reader.Close();
    responseStream. Close();//jhg 06/16/2008
    response.Close( ); //jhg 06/16/2008
    }
    catch (Exception ex)
    {
    onProgressEvent Args args = new onProgressEvent Args("Failed
    to list incoming files from ftp site " + ex.Message);
    showProgress(th is, args);
    }
    }
    is the ftp server load balanced? alternate calls succeed could mean
    load balancing issue.. where one server does not have the file.
    you could use a regular ftp client and connect to the server and see
    what happens try it couple of times in a row.

    just a thought..

    Comment

    • Jeremy

      #3
      Re: ftpWebResponse fails on alternate calls

      "parez" <psawant@gmail. comwrote in message
      news:db31ed80-0583-4ea8-b83e-ded5e7eb40af@k3 0g2000hse.googl egroups.com...
      >
      is the ftp server load balanced? alternate calls succeed could mean
      load balancing issue.. where one server does not have the file.
      you could use a regular ftp client and connect to the server and see
      what happens try it couple of times in a row.
      Not load balanced. FileZilla connects consecutively, although it asks
      "break current connection?" each time. Interesting suggestion though.

      Jeremy

      Comment

      Working...