Error while uploading file occurring randomly
We are using WinSCP to transfer files to a SFTP server by invoking commands in .net code. On the other end, an automated process grabs the file and moves it to another location.
The below is the .Net code being used.
In some cases, when the WinSCP issues the PUT command,
1. it creates the partial file
2. renames it back to original name
3. when the process at the other end moves the file, then our process creates the partial file again and tries to delete the file with original name.
Please see the following log from the SFTP server.
#1: 2015-03-05 22:30:59 <SOURCE IP> - Account\UserID [3346178]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
#2: 2015-03-05 22:31:21 <SOURCE IP> - Account\UserID [3346178]rnfr /in/YYYXXX.xml.filepart - 350 - - - 22
#3: 2015-03-05 22:31:21 <SOURCE IP> - Account\UserID [3346178]rnto /in/YYYXXX.xml - 250 - - - 22
#4: 2015-03-05 22:31:25 <TARGET IP> - Account\UserID [3346215]sent /in/YYYXXX.xml - 226 - 17924096 - 22
#5: 2015-03-05 22:31:26 <TARGET IP> - Account\UserID [3346220]dele /in/YYYXXX.xml - 250 - - - 22
#6: 2015-03-05 22:31:28 <SOURCE IP> - Account\UserID [3346209]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
#7: 2015-03-05 22:31:28 <SOURCE IP> - Account\UserID [3346209]dele /in/YYYXXX.xml - 550 - - - 22
From the log the original file(YYYXXX.xml) is already deleted by the other process (refer #5) and gives the below error.
Unable to SFTP XML file. Error Message: from PutSFTP: There was an error transferring YYYXXX.xml.
Error deleting file 'YYYXXX.xml'. After resumable file upload the existing destination file must be deleted. If you do not have permissions to delete file destination file, you need to disable resumable file transfers.
No such file or directory.
Error code: 2
Error message from server (en): File not found
Request code: 13
Also there is no pattern in the occurrence of this issue i.e not based on file size, date, etc.
We have already included the option confirm off in the script, so resuming should take place as needed. We are using WinSCP Version 5.0.5 (Build 1782).
Is there anything else we need to change/configure ? Let me know what additional info you need from me.
The below is the .Net code being used.
With winscp.StandardInput .WriteLine("option batch abort") .WriteLine("option confirm off") .WriteLine("open sftp://" & username & ":" & password & "@" & remotehost) .WriteLine("option transfer binary") .WriteLine("lcd " & localFilePath) If Not remoteFilePath Is Nothing Then .WriteLine("cd " & remoteFilePath) If remoteFileName Is Nothing Then .WriteLine("put " & localFileName) Else .WriteLine("put " & localFileName & " """ & remoteFileName & """") .Close() End With
In some cases, when the WinSCP issues the PUT command,
1. it creates the partial file
2. renames it back to original name
3. when the process at the other end moves the file, then our process creates the partial file again and tries to delete the file with original name.
Please see the following log from the SFTP server.
#1: 2015-03-05 22:30:59 <SOURCE IP> - Account\UserID [3346178]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
#2: 2015-03-05 22:31:21 <SOURCE IP> - Account\UserID [3346178]rnfr /in/YYYXXX.xml.filepart - 350 - - - 22
#3: 2015-03-05 22:31:21 <SOURCE IP> - Account\UserID [3346178]rnto /in/YYYXXX.xml - 250 - - - 22
#4: 2015-03-05 22:31:25 <TARGET IP> - Account\UserID [3346215]sent /in/YYYXXX.xml - 226 - 17924096 - 22
#5: 2015-03-05 22:31:26 <TARGET IP> - Account\UserID [3346220]dele /in/YYYXXX.xml - 250 - - - 22
#6: 2015-03-05 22:31:28 <SOURCE IP> - Account\UserID [3346209]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
#7: 2015-03-05 22:31:28 <SOURCE IP> - Account\UserID [3346209]dele /in/YYYXXX.xml - 550 - - - 22
From the log the original file(YYYXXX.xml) is already deleted by the other process (refer #5) and gives the below error.
Unable to SFTP XML file. Error Message: from PutSFTP: There was an error transferring YYYXXX.xml.
Error deleting file 'YYYXXX.xml'. After resumable file upload the existing destination file must be deleted. If you do not have permissions to delete file destination file, you need to disable resumable file transfers.
No such file or directory.
Error code: 2
Error message from server (en): File not found
Request code: 13
Also there is no pattern in the occurrence of this issue i.e not based on file size, date, etc.
We have already included the option confirm off in the script, so resuming should take place as needed. We are using WinSCP Version 5.0.5 (Build 1782).
Is there anything else we need to change/configure ? Let me know what additional info you need from me.