Search code examples
c#ftpchilkat

Chilkat FTP2 download (GetFile) large files (≈12 GB)


I've been trying to download large files approx 12GB of size, using Chilkat.Ftp2.

Everything seems to be ok, BUT.. download tends to fail at ~100%, in log I could see:

  GetFile:
    DllDate: Jul 30 2019
    ChilkatVersion: 9.5.0.79
    UnlockPrefix: NONE
    Architecture: Little Endian; 32-bit
    Language: .NET 4.7 / x86
    VerboseLogging: 0
    originalGreeting: 220 Titan FTP Server  Ready.
    remotePath: /fo/bar/export_20190819.zip
    localPath: \test\export_20190819.zip
    ProgressMonitoring:
      enabled: yes
      heartbeatMs: 0
      sendBufferSize: 65536
    --ProgressMonitoring
    downloadToFile:
      localFilePath: \test\export_20190819.zip
      Replacing existing local file
      downloadToOutput2:
        modeZ: 0
        binaryMode: 1
        setupDataConnection:
          passive transfer mode
          setupPassiveDataSocket:
            sendCommand:
              sendingCommand: PASV
            --sendCommand
            readCommandResponse:
              WindowsError: An existing connection was forcibly closed by the remote host.
              WindowsErrorCode: 0x2746
              maxToReceive: 65536
              Failed to receive data on the TCP socket
              Failed to read FTP control channel reply.
              readFtpReply: Socket fatal error.
            --readCommandResponse
          --setupPassiveDataSocket
          Failed to setup passive data socket
        --setupDataConnection
        Failed to setup data connection for download.
        readRepliesAfterFailedDataConn:
          readCommandResponse:
            Failed to read FTP control channel reply.
            readFtpReply: Socket connection closed.
          --readCommandResponse
        --readRepliesAfterFailedDataConn
      --downloadToOutput2
      downloadToOutput: Elapsed time: 18953 millisec
    --downloadToFile
    Failed.   --GetFile
--ChilkatLog  

What I've tried so far is to set:

ftp.EnableEvents = true;
ftp.RestartNext = true;
ftp.Passive = false;
ftp.SoSndBuf = 131072;
ftp.SoRcvBuf = 131072;

Also calling ftp.Noop(); time to time, to keep connection "alive".

Am I missing something here?

EDIT: Some pseudo code of download and retry

        string fileName = _ftp.GetFilename(i);
        string remoteFilePath = sourcePath + fileName;
        string destinationFilePath = destinationPath + fileName;
        bool success = _ftp.GetFile(remoteFilePath, destinationFilePath);

        if (success)
        {
            Log($"Downloading Finished {fileName} : {DateTime.Now.ToString("HH:mm:ss")}");
        }
        else
        {
            Thread.Sleep(30000);
            success = _ftp.GetFile(remoteFilePath, destinationFilePath);
        }

Solution

  • Setting the ftp.LargeFileMeasures = true should solve the problem.