FluentFTP: UploadFile returns Success but file is only partially uploaded

FTP Server OS: Synology

FTP Server Type: Synology 7.1.x

Client Computer OS: Windows

FluentFTP Version: 34.0.2 ~ 48.0.3

Framework: .NET core 2.2 ~ 8

Maybe #1358 has a similar issue like mine but just doesn’t know it.

So i basically have always uploaded to a very remote server with bad connection circumstances. A couple of weeks ago i’m using wifi (yes i know) to upload files to the ftp server and am suffering even more upload issues.

And today i finally noticed the UploadFile method returning success while the upload wasn’t fully uploaded yet. But if i run GetFileSize it’s able to correctly return the correct size from the remote file. So as a work around i have added a extra check after i’m done uploading a file to check the size, and to resume the upload until it’s completed.

Logs :


<paste VERBOSE logs here>

Code:

// here i create a AsyncFtpClient, no weird configs\overrides fyi

for (var i = 1; i < 99; i++)
{
    try
    {
        if (!ftpclient.IsConnected || !ftpclient.IsAuthenticated)
        {
            await ftpclient.Connect(uploadProfile);
        }

        var result = await ftpclient.UploadFile(
            archivePath,
            $"/{DateTime.Now:yyyy-MM-dd}/" + archiveFileName,
            FtpRemoteExists.Resume,
            true,
            FtpVerify.Retry,
            new Progress<FtpProgress>(p => progress.Tick((int)p.Progress, p.ETA, $"{p.TransferSpeedToString()} uploading to ftp... attempt: {i}")));

        //// i have some code here now that double checks the filesize and prevents it from breaking the loop.

        if (result == FtpStatus.Success)
        {
            break;
        }
    }
    catch (Exception ex)
    {
       //// some logging code etc, also just restarts the loop
    }

    if (ftpclient.IsConnected)
    {
        await ftpclient.Disconnect();
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 26 (1 by maintainers)

Most upvoted comments

So, although we have not found out why the transfers are being interrupted somewhere down the line, you have implemented a retry scheme that works after a few bugs were fixed. Thanks for helping us to find and debug them.

I suppose we can close this - as I don’t think this is a FluenFTP code problem.

Just for your information: I have found and fixed an issue which causes some problems and I would like you to redo the “Attempt 1…Attempt 6,7” for me (as you did above) and to post the new log in here. I need to see at least on complete connect-FEAT-etc. also. Please use the current master in here as I have commited and merged the fixes already.

Maybe https://github.com/robinrodricks/FluentFTP/issues/1358 has a similar issue like mine but just doesn’t know it.

You were right, the problems you are seeing are related to this. But it isn’t the total solution - we still now need to debug why the APPE command is not working right and why the server is behaving in such a strange way.