0 votes
by (120 points)

I am using Rebex Total Pack for .NET 2019 R3.

When attempting to rename the file on external SFTP server i get the following error: SftpException: Failure; Failure.

We run a rename on the server using the same name to ensure the file is not locked. This hasnt caused issues on other servers so i am guessing it has something to do with the server we are connecting to but we are able to rename the file to other names, just not the same name. Below is a snippet of the log we generated to see if this helps. Let me know if you need something else - Thank You

2019-07-16 18:31:42.910 DEBUG Sftp(3)[9] Info: Item: -rwxrwxrwx    1 justin.dickerson users    290016512 Jul 16 16:12 CHFLpdf.zip
2019-07-16 18:31:42.910 DEBUG Sftp(3)[9] Info: Item: -rwxrwxrwx    1 justin.dickerson users    82922585 Jul 16 16:42 CHSLpdf.zip
2019-07-16 18:31:42.910 DEBUG Sftp(3)[9] Info: Item: drwxrwxrwx   11 justin.dickerson users        4096 Jul 15 12:52 March2019
2019-07-16 18:31:42.910 DEBUG Sftp(3)[9] Info: Item: -rwxrwxrwx    1 osg_user users           0 Jul 15 16:58 test.txt
2019-07-16 18:31:42.910 DEBUG Sftp(3)[9] Info: Item: -rwxrwxrwx    1 osg_user users      140695 Jul 16 18:22 testTWNC_Broadcast_Overnight_071219.zip
2019-07-16 18:31:42.910 INFO Sftp(3)[9] Command: SSH_FXP_READDIR (6, 0x0)
2019-07-16 18:31:42.973 INFO Sftp(3)[9] Response: SSH_FXP_STATUS (6, 1, 'End of file')
2019-07-16 18:31:42.973 INFO Sftp(3)[9] Command: SSH_FXP_CLOSE (7, 0x0)
2019-07-16 18:31:43.034 INFO Sftp(3)[9] Response: SSH_FXP_STATUS (7, 0, 'Success')
2019-07-16 18:31:46.120 INFO Sftp(3)[9] Command: SSH_FXP_STAT (8, '/OSG/1-ToBeProcessed/testTWNC_Broadcast_Overnight_071219.zip')
2019-07-16 18:31:46.519 INFO Sftp(3)[9] Response: SSH_FXP_ATTRS (8)
2019-07-16 18:31:47.423 INFO Sftp(3)[9] Command: SSH_FXP_RENAME (9, '/OSG/1-ToBeProcessed/testTWNC_Broadcast_Overnight_071219.zip', '/OSG/1-ToBeProcessed/testTWNC_Broadcast_Overnight_071219.zip')
2019-07-16 18:31:47.481 INFO Sftp(3)[9] Response: SSH_FXP_STATUS (9, 4, 'Failure')
2019-07-16 18:31:47.519 ERROR Sftp(3)[9] Info: Rebex.Net.SftpException: Failure; Failure.
   at vond.mcme(jrlq arf, Type arg)
   at vond.mclu(String aqd, String aqe, Boolean aqf, vomm aqg)
   at Rebex.Net.Sftp.ieja(String sh, String si, vomm sj)
Applies to: Rebex SFTP

1 Answer

0 votes
by (148k points)

This exception occured because the SFTP server refused to renamed the file and reported an error. Unfortunately, the error status reported by the server is rather meaningless - one "Failure" in the message represents SFTP protocol's SSH_FX_FAILURE status, which indicates "a generic catch-all error" to be returned "when there is no more specific error code defined". The other "Failure" represents the error message reported with the server along with the status code. Unfortunately, this isn't very useful either.

However, perhaps the cause for the error is simple. Based on your log, it looks like you are passing the same path as both target and source. Paths copy&pasted from your log's SSH_FXP_RENAME entry:

/OSG/1-ToBeProcessed/testTWNC_Broadcast_Overnight_071219.zip
/OSG/1-ToBeProcessed/testTWNC_Broadcast_Overnight_071219.zip

Please make sure to always specify a different target path when renaming a file and let us know if the issue persists.

by (120 points)
Thank you for your response. As i mentioned in my original question, we currently do this for other servers. Using the rename with same path/name to check if file is locked. We have no issues with other servers so i was wondering if there was more information i can provide the owners of the ftp server what to check for besides a generic "Failure". We need to keep original name so we either have to rename file twice before downloading or if you have another suggestion let me know.
by (148k points)
Oh, sorry, I somehow managed to skip that part of your original question, concentrating on the log instead! In that case, there are really no additional information to supply to the server vendor because the SSH_FXP_STATUS response only contains the error message and the status code (both of which just indicate "failure").

However, please be aware that even though this SFTP server's response is not very helpful, it actually behaves according to the protocol. On the other hand, SFTP servers that actually do allow SSH_FXP_RENAME with identical paths (and don't fail) are violating the protocol, which explicitly states that:
"It is an error if there already exists a file with the name specified by newpath."
(https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-6.5)

So renaming twice might be a more compatible option. Alternatively, consider using Sftp object's GetStream method to open the file in appropriate mode. If it succeeds, just close the stream. If you don't call any Read or Write methods on it, no data would be transferred.
by (120 points)
Ok, so if currently the others are violating protocol by allowing renaming using identical paths then i would rather correct this before it becomes an issue if they do any updates. I will change to one of the other options mentioned. Thank you for your assistance
...