When uploading large files Say 200-300 MB using ,net Library it fails with error code 4

Advertisement

coolshashi
Joined:
Posts:
7
Location:
San Jose, CA

When uploading large files Say 200-300 MB using ,net Library it fails with error code 4

I get an exception and transfer of file fails when using WinSCP .net version 5.7.5

I am using SynchronizeDirectories method.

It has no issue uploading smaller files.


I get errors sometime with FileZilla too but it seems to (Error: error while writing: failure") to correct itself and succeed uploading the file.

Please help.

Shashi

Reply with quote

Advertisement

coolshashi
Joined:
Posts:
7
Location:
San Jose, CA

The error message I get is

Upload of \\ProjectFiles\2015.09.01_5509\C6KA.zip failed: WinSCP.SessionRemoteException: Cannot close remote file 'C6KA.zip'. ---> WinSCP.SessionRemoteException: General failure (server should provide error description).
Error code: 4
Error message from server: Failure

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: When uploading large files Say 200-300 MB using ,net Library it fails with error code 4

Well, it's obviously a server-side problem. So please contact a server administrator first.

Reply with quote

coolshashi
Joined:
Posts:
7
Location:
San Jose, CA

Thanks a lot for the reply. But I never get any issue with FileZilla finishing the job. Even if I see some errors it seems to finish.

I copy using FileZilla. Not synchronize.

For a new directory is it better to try copying instead of snychronize ?

Is there any difference using the WinSCP.exe with command line to .net library ?

Are there any additional flags that only availabele in command prompt that can help me ?

Shashi

Reply with quote

coolshashi

I also see a .filepart file on the remote server when the error happens. Does this mean it has issues renaming that .filepart file to what ever the real extension ?

Reply with quote

Advertisement

coolshashi
Joined:
Posts:
7
Location:
San Jose, CA

I am pasting my code here for you to look at so that you can tell me if there is anything i am missing.

remoteSession_FileTransferred errros out consistently on a large file. Once it has errored out on a file it seems to keep doing that when i re try too.

The file it gives me trouble is around 198MB and it fails around 187MB. I see a 187MB file that has .filepart extension of remote site.

private void SyncFolders(string srcPath, string dstPath, bool bCreateDestFolder = false)
        {
            if (Directory.Exists(srcPath))
            {
                if (bCreateDestFolder)
                {
                    if (!remoteSession.FileExists(dstPath))
                    {
                        remoteSession.CreateDirectory(dstPath);
                    }
                }
                remoteSession.SynchronizeDirectories(SynchronizationMode.Remote, srcPath, dstPath, true);
            }
        }
        private void ReleaseSoftwareToLfoundary()
        {
            UpdateStatus("Updating LFoundry FTP Site ..Please wait");
            WinSCP.SessionOptions sessionOpts = new SessionOptions();
            sessionOpts.HostName = "sftp.lfoundry.com";
            sessionOpts.PortNumber = 7788;
            sessionOpts.UserName = "username";
            sessionOpts.Password = "password";
            sessionOpts.Protocol = Protocol.Sftp;
            sessionOpts.GiveUpSecurityAndAcceptAnySshHostKey = true;
            sessionOpts.TimeoutInMilliseconds = 500000;
            

            bFTPFileTransferError = false;

            remoteSession = new Session();
            remoteSession.FileTransferred += new FileTransferredEventHandler(remoteSession_FileTransferred);
            remoteSession.Open(sessionOpts);

            
            int nCount = 0; 
            while (remoteSession.Opened == false)
            {
                Thread.Sleep(200);
                nCount++;
                if (nCount == 25)//wait for 5 secs 
                {
                    itemsFailed++;
                    AppendToLog("Connecting FTP server Failed");
                    return;
                }
            }
            try
            {
               
                srcPath = PublishFolder + @"ProjectFiles\" + VersionNumber;
                dstPath = @"ProjectFiles/" + VersionNumber;
                SyncFolders(srcPath, dstPath, true);

            }
            catch(Exception _ex)
            {

            };
      
        }
        private void remoteSession_FileTransferred(object sender, TransferEventArgs e)
        {
            if (e.Error != null)
            {
                bFTPFileTransferError = true;
                string message = string.Format("Upload of {0} failed: {1}", e.FileName, e.Error);
                AppendToLog(message);
            }
            else
            {
                string message = string.Format("Trasfered file {0} To FTP Site", e.FileName);
                AppendToLog(message);
            }
        }

Reply with quote

coolshashi
Joined:
Posts:
7
Location:
San Jose, CA

I also tried switching off TransferResumeSupport, but Still I get teh same issue.

With

transferOptions = new TransferOptions();
transferOptions.ResumeSupport.State = TransferResumeSupportState.Off;

remoteSession.SynchronizeDirectories(SynchronizationMode.Remote, srcPath, dstPath, true,false, SynchronizationCriteria.Time, transferOptions);
[/code]

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

coolshashi wrote:

Thanks a lot for the reply. But I never get any issue with FileZilla finishing the job. Even if I see some errors it seems to finish.
You wrote that FileZilla has the problem too. The difference might be that FileZilla just displays the error and continues.

I also see a .filepart file on the remote server when the error happens. Does this mean it has issues renaming that .filepart file to what ever the real extension ?
No. The error occurs when the uploaded file (the .filepart) closes. So WiSCP won't even try to rename the file.

Reply with quote

Advertisement

You can post new topics in this forum