奇尔卡特 FTP2 下载 (GetFile) 大文件 (≈12 GB)
Chilkat FTP2 download (GetFile) large files (≈12 GB)
我一直在尝试使用 Chilkat.Ftp2 下载大约 12GB 的大文件。
一切似乎都很好,但是.. 下载往往会在 ~100% 时失败,在日志中我可以看到:
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
到目前为止我试过的是设置:
ftp.EnableEvents = true;
ftp.RestartNext = true;
ftp.Passive = false;
ftp.SoSndBuf = 131072;
ftp.SoRcvBuf = 131072;
还时不时打电话给ftp.Noop();
,以保持联系"alive"。
我是不是遗漏了什么?
编辑:一些下载和重试的伪代码
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);
}
设置 ftp.LargeFileMeasures = true 应该可以解决问题。
我一直在尝试使用 Chilkat.Ftp2 下载大约 12GB 的大文件。
一切似乎都很好,但是.. 下载往往会在 ~100% 时失败,在日志中我可以看到:
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
到目前为止我试过的是设置:
ftp.EnableEvents = true;
ftp.RestartNext = true;
ftp.Passive = false;
ftp.SoSndBuf = 131072;
ftp.SoRcvBuf = 131072;
还时不时打电话给ftp.Noop();
,以保持联系"alive"。
我是不是遗漏了什么?
编辑:一些下载和重试的伪代码
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);
}
设置 ftp.LargeFileMeasures = true 应该可以解决问题。