Filetransfer successful but File does not exist on remote server

Advertisement

paddytokey
Guest

Filetransfer successful but File does not exist on remote server

I'm upload a bunch of XML files to an FTP Server using a batch file that calls WinSCP, which uses as script file to upload all XML files from a local folder to the SFTP target location. This happens once every hour and usually goes fine, however we've now come across several cases where the files never arrived on the SFTP target.
I'm using /log to create a logfile of the uploads, and a loop to restart the upload in case of an error.
However, in these cases, the log does not show any error, it shows that the file has been uploaded successfully. Here's an excerpt of the log from a file I know has not been transferred succesfully:
. 2020-04-30 12:30:02.790 File: 'File_Name_123.xml' [2020-04-30T10:15:30.867Z] [337]
. 2020-04-30 12:30:02.791 Copying "File_Name_123.xml" to remote directory started.
. 2020-04-30 12:30:02.791 Binary transfer mode selected.
. 2020-04-30 12:30:02.792 Opening remote file.
> 2020-04-30 12:30:02.792 Type: SSH_FXP_OPEN, Size: 52, Number: 45059
< 2020-04-30 12:30:02.803 Type: SSH_FXP_HANDLE, Size: 13, Number: 45059
> 2020-04-30 12:30:02.803 Type: SSH_FXP_WRITE, Size: 362, Number: 45574
> 2020-04-30 12:30:02.804 Type: SSH_FXP_CLOSE, Size: 13, Number: 45828
> 2020-04-30 12:30:02.804 Type: SSH_FXP_SETSTAT, Size: 48, Number: 45321
< 2020-04-30 12:30:02.816 Type: SSH_FXP_STATUS, Size: 24, Number: 45574
< 2020-04-30 12:30:02.816 Status code: 0
< 2020-04-30 12:30:02.817 Type: SSH_FXP_STATUS, Size: 24, Number: 45828
< 2020-04-30 12:30:02.817 Status code: 0
. 2020-04-30 12:30:02.817 Preserving timestamp [2020-04-30T10:15:30.000Z]
< 2020-04-30 12:30:02.827 Type: SSH_FXP_STATUS, Size: 24, Number: 45321
< 2020-04-30 12:30:02.828 Status code: 0
. 2020-04-30 12:30:02.828 Transfer done: 'File_Name_123.xml' => '/in/File_Name_123.xml' [337]
I've had an upload where only 13 out of 58 files were transmitted, however no error appears in the log file.
Is there any way to verify the transmission? Could there be a setting I'm missing that causes this behaviour?
Files are typically around 1-3KB in size, an upload can contain anywhere from 20 to 200 files.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,541
Location:
Prague, Czechia

Re: Filetransfer successful but File does not exist on remote server

The server acknowledged the upload. So from the perspective of WinSCP, the upload succeeded. If the file were lost somewhere on the server, you will have to check server-side logs. All you can do from client side is to list remote directory after the upload and verify that the files are there. You cannot do such verification automatically in the WinSCP script though. That would require a more advanced language. Though I'm quite sure that this will turn out to be some misunderstanding. It does not really happen that a server acknowledges a transfer and then loses the files.

Reply with quote

paddytokey
Guest

Re: Filetransfer successful but File does not exist on remote server

Hi martin,
thanks for your reply.

I would think the same, unfortunately I have no access to Logs from the receiving server and their support hit me with a "well it looks like the files where never uploaded, otherwise they would be on the server" ...

Since I'm not a developer by any means, I have no experience in coding and had hoped there would be an easier explanation or way around.

The weirdest thing about all of this is the fact that we can verify some of the files transfered in this particular batch have been received and processed by the receiving end, while some haven't but ALL of them are marked as transfered in the log. To make things worse: there seems to be no pattern, it's not like the last third fails or the beginning or whatever, the failed uploads were just spread across the whole batch of files.

Sorry I'm just venting, thank you for taking the time to respond. I'll be looking for another way to get those files over there, perhaps I can zip them and transfer that file, then unzip on the server to make sure all of them are in the batch.

Reply with quote

martin
Site Admin
martin avatar

Re: Filetransfer successful but File does not exist on remote server

For a start, just add ls command after the upload. It will at least log the list of files on the server, so you will have some evidence, when talking to the server owners.

Reply with quote

rkendx
Guest

WinSCP Upload Check() Success but File Not on Remote Server

I'm observing a similar result as the post with the Subject "Re: Filetransfer successful but File does not exist on remote server". I'm using PowerShell to load WinSCPnet.dll and then after calling PutFiles(), I call the transferResult.Check() and no error is thrown. Further the transferResult.Transfers list the zip file that was uploaded. I've verified the remote path matches the actual path on the server and I see no file on the target server when logging as the same user.

Any other tips to diagnose why the upload indicates success but the target server does not show it was received? My script resembles the sample with the addition of disabling ResumeSupport: https://winscp.net/eng/docs/library_powershell
Try {
    Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
 
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = $ftpUrl
        UserName = $ftpUser
        Password = $ftpPassword
        SshHostKeyFingerprint = "ssh-rsa 2048 ..."
    }
    $session = New-Object WinSCP.Session
 
    try
    {
        $session.Open($sessionOptions)
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
        $transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
 
        $transferResult = $session.PutFiles("$SourcePath\$zipFileName", '$RemotePath$zipFileName', $False, $transferOptions)
        
        # Throw on any error
        $transferResult.Check()
 
        foreach ($transfer in $transferResult.Transfers)
        {
            LogMessage "Upload of $($transfer.FileName) succeeded here: $remotePath$zipFileName"
        }
    }
    finally
    {
        $session.Dispose()
    }
}
Catch {
    $successful = $False
    LogMessage "FTP Failed: $_.Exception.Message" -ErrorAction Continue
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,541
Location:
Prague, Czechia

Re: WinSCP Upload Check() Success but File Not on Remote Server

See my answer above.
See also Why is uploaded file not showing in a remote directory or showing with a different name?.
If you need further assistance, please share much more information. 1) Log files. 2) If you call ListDirectory right after PutFiles, does the result include the uploaded file? Post logs of that too. 3) If you upload in GUI, can you see the file in the remote folder? 4) What if you upload in any other client?

Reply with quote

Advertisement

You can post new topics in this forum