Home Forums .NET libraries Xceed SFTP/FTP for .NET Error downloading file from the server

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20962 |

    I am evaluating your http://FTP.net library and I am facing some problem while retrieving files from my server. Even the file is download to client (Server log shows 226 Transfer ok) and the progress bar shows that the file has been completed (%100), Ftp client gives timed-out exception.

    Please help me to solve the problem.

    My code is: (I am using snippet explorer)

    FtpClient client = new FtpClient();

    // We want all events to be raised on the main UI thread.
    client.SynchronizingObject = m_resultsForm;

    client.TraceWriter = Console.Out;
    client.FileTransferStatus += new FileTransferStatusEventHandler( OnFileTransferStatus );

    string remoteFilename = “P200S001/Images/07-08-2005/00003/4453/CR-1/1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm”;
    string localFilename = System.IO.Path.GetTempPath() + @”SnippetExplorer\1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm”;

    try
    {
    // Connect …
    client.Connect( “a.b.c.d”, 201);
    client.Login(“P200U001 “, “xx”);

    Console.WriteLine( “Logged-in!” );

    client.ReceiveFile( remoteFilename, localFilename );

    Console.WriteLine( “The file was saved as {0}”, localFilename );
    }
    finally
    {
    try
    {
    if( client.Connected )
    {
    client.Disconnect();
    }
    }
    catch {}

    Console.WriteLine( “Disconnected!” );

    // Unsubscribe from events.
    client.FileTransferStatus -= new FileTransferStatusEventHandler( OnFileTransferStatus );
    }

    Server Log is:
    > 230 User P200U001 logged in.
    > TYPE I
    > 200 Type set to I.
    > PASV
    > 227 Entering Passive Mode (a,b,c,d,136,220)
    > RETR P200S001/Images/07-08-2005/00003/4453/CR-1/1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm
    > asked to download ‘D:\P200S001\Images\07-08-2005\00003\4453\CR-1\1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm’ –> Access allowed.
    > 150 Data connection accepted from x.y.z.w:1122; transfer starting for 1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm (3167292 bytes).
    > started downloading ‘D:\P200S001\Images\07-08-2005\00003\4453\CR-1\1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm’.
    > finished downloading ‘D:\P200S001\Images\07-08-2005\00003\4453\CR-1\1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm’ – (00:00:58 – 3093.059 KB – 53.329 KBytes/s)
    > 226 Transfer ok
    > QUIT
    > 221 Bye bye …
    > disconnected.

    Client Log is:
    ….
    > 230 User P200U001 logged in.
    Logged-in!
    > TYPE I
    < 200 Type set to I.
    > PASV
    < 227 Entering Passive Mode (a,b,c,d,136,220)
    > RETR P200S001/Images/07-08-2005/00003/4453/CR-1/1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm
    Data connection established with a.b.c.d:35036 on 21.01.2008 @ 19:52:53
    > 150 Data connection accepted from x.y.z.w:1122; transfer starting for 1.2.392.200046.100.2.1.400046.4453.20050708124912.1.1.1.zdcm (3167292 bytes).
    > QUIT
    Disconnected from a.b.c.d:201 on 21.01.2008 @ 19:54:21
    Disconnected!
    Error: The FTP command execution timed-out

    Thanks.
    Ozcan

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Ozcan (had 2579 views)

    User (Old forums)
    Member
    Post count: 23064

    What can happen is that the firewall closes the command channel, while the transfer keeps going on on the data channel. The reason for this is that the firewall, not seeing any communication on the command channel, closes it after a certain time. So when the server has finish transferring the data (on the data channel), it send the reply (on the command channel) to tell the client that the transfer is done, but the reply does go through, so the component never receive the the reply, and it times out at a certain point.

    However, in your case we are talking about a file that is only 3MB big, and that takes less than a minute to download, so I’m a bit surprise the firewall would close the command channel so fast.

    Anyhow, if this is the issue, there is three possible solution to this issue. You can set the KeepAliveInterval property (which send a NOOP command to the server on the command channel at a specified interval) to a value, in seconds, that is bellow the firewall threshold for closing the connection. Or, if you have access to it, set the firewall so it does not close an ftp connection, or set a greater threshold time. Last, you can monitor the size of the file, and when you know the whole file has been transfered, you can call the Abort() method, and then you will be able to continue your process.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 3919 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.