Repository navigation
An error occurred, but no specific error code exists to describe the failure #1735
Description
Hi,
I'm getting the below error on various version ( including 2025.1.0 )
Unhandled exception occurred Renci.SshNet.Common.SshException: Failed to upload /2880389.xml to ./2880389.xml
---> Renci.SshNet.Common.SftpException: An error occurred, but no specific error code exists to describe the failure.
at Renci.SshNet.Sftp.SftpSession.RequestClose(Byte[] handle)
at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, Flags flags, SftpUploadAsyncResult asyncResult, Action`1 uploadCallback, Boolean isAsync, CancellationToken cancellationToken)
at Renci.SshNet.SftpClient.InternalSynchronizeDirectories(String sourcePath, String destinationPath, String searchPattern, SftpSynchronizeDirectoriesAsyncResult asyncResult)
--- End of inner exception stack trace ---
I'm properly connected to the SFTP server:
Files in remote directory ./username: ["processing"]
Current working directory: /
And I'm able to successfully upload a file using lftp:
lftp -u username sftp://some_server.com -e "put /tmp/test.xml -o /test5.xml; bye"
I don't have problems downloading files from this server.
Telnet to the server reoprts:
SSH-2.0-DataPowerSSH_1.1
I've been trying both:
SftpClient.Upload and SftpClient.SynchronizeDirectories(sourcePath, ".", "*.xml")
Any idea what might be causing the problem?
Tried to specify the remote path as / , ./ and ./username
Thanks
edi1
Maybe debug logs will be useful and also the fact, the server only supports: ssh-rsa
info: Renci.SshNet.Connection.DirectConnector[0]
Initiating connection to 'Unspecified/some_server.com:22'.
info: Renci.SshNet.Session[0]
Server version 'SSH-2.0-DataPowerSSH_1.1'.
dbug: Renci.SshNet.Session[0]
[(null)] Performing curve25519-sha256 key exchange.
dbug: Renci.SshNet.Security.KeyExchangeECCurve25519[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Creating aes128-ctr server cipher.
dbug: Renci.SshNet.Security.KeyExchangeECCurve25519[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Creating aes128-ctr client cipher.
dbug: Renci.SshNet.Security.KeyExchangeECCurve25519[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Creating hmac-sha2-256 server hmac algorithm.
dbug: Renci.SshNet.Security.KeyExchangeECCurve25519[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Creating hmac-sha2-256 client hmac algorithm.
dbug: Renci.SshNet.SftpClient[0]
Disposing client.
info: Renci.SshNet.SftpClient[0]
Disconnecting client.
dbug: Renci.SshNet.Session[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Disposing session.
info: Renci.SshNet.Session[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Disconnecting session.
dbug: Renci.SshNet.Session[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Shutting down socket.
dbug: Renci.SshNet.Session[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Disposing socket.
dbug: Renci.SshNet.Session[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Disposed socket.
info: Renci.SshNet.Session[0]
[5ACDE0EBBF5E5D1ACBF0B8452F18745B0D6126EFB878BD01C445FCD9FD937224] Raised exception
Renci.SshNet.Common.SshConnectionException: Software caused connection abort
---> System.Net.Sockets.SocketException (53): Software caused connection abort
at Renci.SshNet.Abstractions.SocketAbstraction.Read(Socket socket, Byte[] buffer, Int32 offset, Int32 size, TimeSpan readTimeout)
at Renci.SshNet.Session.TrySocketRead(Socket socket, Byte[] buffer, Int32 offset, Int32 length)
at Renci.SshNet.Session.ReceiveMessage(Socket socket)
at Renci.SshNet.Session.MessageListener()
--- End of inner exception stack trace ---
Activity
Rob-Hague commentedon Nov 13, 2025
Unfortunately this generic error can mean anything depending on the implementation of the server. Sometimes it can be e.g. part of the path does not exist and the server says "Failure" rather than "NoSuchFile". It is odd though that is seems to be happening when closing the file. Does the file exist on the server after the error?
The library has quite a lot of "path canonicalisation" stuff (
SSH.NET/src/Renci.SshNet/Sftp/SftpSession.cs
Line 94 in e5ad82c
The logs look fine. I imagine the server logs would have more information but guessing this is not your server.
eLPe21 commentedon Nov 13, 2025
Hi , thanks for reply.
Progress logs even shows % upload , but the file, never shows up on the server at all. Neither during upload ( tried to list the folder during uploads ) or after it.
And yeah, it's not my server so I'm limited a bit to what I've provided. WIll try to contact server-admin but being able to upload files manually using LFTP made me create this issue.
Tried to clone the sources and force to use the path provided skipping canonical path , but big chance I've done something wrong.
Rob-Hague commentedon Nov 13, 2025
It might be sufficient to try this as an experiment:
I can see that lsftp does request the current path: https://github.com/lavv17/lftp/blob/926cbf31a87aed00b7ab38298783302908c0d0e7/src/SFtp.cc#L220
and it does seem to use it in some (as yet uncertain) circumstances: https://github.com/lavv17/lftp/blob/926cbf31a87aed00b7ab38298783302908c0d0e7/src/SFtp.cc#L588
https://github.com/lavv17/lftp/blob/926cbf31a87aed00b7ab38298783302908c0d0e7/src/SFtp.cc#L555
lsftp also seems to print some relevant information at debug level 9. (SSH.NET would also print more at "Trace" but probably not enough at the SFTP level unfortunately)
eLPe21 commentedon Nov 14, 2025
Maybe that will help, enable trace, also overwrite the fullPath as per your suggestion, tried
to list files from the server and the file never appeared on the server.
Rob-Hague commentedon Nov 17, 2025
Sadly not 🙁 the library is lacking when it comes to logging SFTP messages. Did you have any luck with the debug output from lftp?
eLPe21 commentedon Nov 17, 2025
All is ok when I use LFTP.
lftp -d -u user,pass sftp://some_server.com -e "mput 2907758.xml; bye"
---- Running connect program (ssh -a -x -s -l user some_server sftp)
---> sending a packet, length=5, type=1(INIT), id=0
<--- user@some_server's password: XXXX
<--- got a packet, length=5, type=2(VERSION), id=0
---- protocol version set to 3
---> sending a packet, length=10, type=16(REALPATH), id=1
<--- got a packet, length=89, type=104(NAME), id=1
---- home set to /
---- path on wire is `/2907758.xml'
---> sending a packet, length=29, type=3(OPEN), id=2
<--- got a packet, length=21, type=102(HANDLE), id=2
---- got file handle 374634314238374135433130 (12)
---> sending a packet, length=8234, type=6(WRITE), id=3
---> sending a packet, length=33, type=10(FSETSTAT), id=4
---> sending a packet, length=21, type=4(CLOSE), id=5
<--- got a packet, length=17, type=101(STATUS), id=3
---- status code=0(OK), message=
<--- got a packet, length=17, type=101(STATUS), id=4
---- status code=8(Operation not supported), message=
<--- got a packet, length=17, type=101(STATUS), id=5
---- status code=0(OK), message=
8201 bytes transferred in 2 seconds (3.6K/s)
---- Disconnecting
Rob-Hague commentedon Nov 17, 2025
Could you try -d9 if it does not give too much private information?
eLPe21 commentedon Nov 17, 2025
Not sure if this going to be any helpful , trying to get server logs, but it's not easy ;)
lftp user@some_server:/> debug 9
lftp user@some_server:/> mput /2907533.xml
---- path on wire is `/2907533.xml'
---> sending a packet, length=29, type=3(OPEN), id=7
<--- got a packet, length=21, type=102(HANDLE), id=7
---- got file handle 374634333442333931363130 (12)
---- eof
---> sending a packet, length=32801, type=6(WRITE), id=8
---> sending a packet, length=11370, type=6(WRITE), id=9
---> sending a packet, length=41, type=10(FSETSTAT), id=10
---> sending a packet, length=21, type=4(CLOSE), id=11
<--- got a packet, length=17, type=101(STATUS), id=8
---- status code=0(OK), message=
<--- got a packet, length=17, type=101(STATUS), id=9
---- status code=0(OK), message=
<--- got a packet, length=17, type=101(STATUS), id=10
---- status code=8(Operation not supported), message=
<--- got a packet, length=17, type=101(STATUS), id=11
---- status code=0(OK), message=
44105 bytes transferred
lftp user@some_server:/>
eLPe21 commentedon Nov 21, 2025
@Rob-Hague almost there ;)
Managed to get some logs from the sever side. I've been told the problem is that I'm trying to upload file to
USER_NAME/file_name
instead of /file_name
Line 18328: 20251121T102157.050Z [0x80000001][xsltmsg][info] : tid(293587409)[request] gtid(8a7709fd69203d45117fc9d1): InternalDestination = {REDACTED}/some_user/2880389.xml
Line 18329: 20251121T102157.050Z [0x80e00117][mpgw][info] : tid(293587409) gtid(8a7709fd69203d45117fc9d1): Destination URL is now {REDACTED}/some_user/2880389.xml
Line 18686: 20251121T102157.392Z [0x80e00096][ftp][debug] : tid(293587409) gtid(8a7709fd69203d45117fc9d1): reply code 451 in state 'Write Data' from {REDACTED}/some_user/2880389.xml. Reply text: ' requested action aborted: local error in processing'
Line 18687: 20251121T102157.392Z [0x80e0047c][ftp][notice] : tid(293587409) gtid(8a7709fd69203d45117fc9d1): file write failed for URL '{REDACTED}/some_user/2880389.xml', server response '451 requested action aborted: local error in processing
Line 18697: 20251121T102157.392Z [0x81000171][mpgw][debug] Matching(Match_all): tid(293587409) gtid(8a7709fd69203d45117fc9d1): Match: Received URL [/some_user/2880389.xml] matches rule '*'
Line 18715: 20251121T102157.393Z [0x80e00487][sftp][error] : tid(293587409) gtid(8a7709fd69203d45117fc9d1): SFTP Server: SSH_FXP_CLOSE [/some_user/2880389.xml] failure.
Rob-Hague commentedon Nov 21, 2025
Interesting, thanks, I'll take a closer look over the weekend
Rob-Hague commentedon Nov 23, 2025
That is the value of sftpClient.WorkingDirectory?
I suspect the issue is coming from one of the calls to SftpSession.GetCanonicalPath. It is quite difficult to understand the logic there.
SSH.NET/src/Renci.SshNet/Sftp/SftpSession.cs
Line 95 in 8712c99
e.g. if I do
then at some point it calls RequestRealPath with path =
/./test.txtwhich seems a bit odd. But against OpenSSH server this returns/test.txtso it is ok.eLPe21 commentedon Nov 23, 2025
Yes it is -> Current working directory being / returned by sftpClient.WorkingDirectory
The thing they told me about the server is that ( I might be saying gibberish now ) that they use sftp for authentication etc
but then the transfer is happening to some different server internally. Not sure if I understood that properly,
haven't tried to do something like that myself.
But I took it as
upload to /username/put.xml works ok but then internally the next step is failing as /username/ is invalid path as it should be just put.xml