0 votes
by (220 points)

I am writing a client to upload data to sftp server. For that I am using Rebex file transfer pack (4.0.6930). I am using rebex tiny sftp server for development purpose.

I get error logs on sftp server about socket exceptions but I don't get any exception on client side and file also uploads.

Below are the logs that are written on rebex tiny sftp server:
17:17:28.942 Error Server: Session 1697: Error: : Error while processing packet SSH_MSG_CHANNEL_DATA. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at .( ) at .( ) at .() at .(SshPacketType ,  ) at .(SshPacketType ,  ) at .(Int32 , Int32 ) --- End of inner exception stack trace --- at .(Int32 , Int32 ) at .() at .(Int32 , Int32 , Int32 , Int32 , SocketException )

I am just wondering what exception will be thrown on file transfer client in case of socket exception (System.Net.SocketException or Rebex.Net.SshException)?

So that I can handle this exception accordingly.

Also I checked that StatusCode enum values of Rebex.Net.SshException are different than System.Net.Sockets.SocketError enum values.
Is there a way to map between these two?

1 Answer

0 votes
by (70.4k points)

From Sftp client class you will "always" get the SftpException object - if the error was caused by a SocketException or IOException or anything else, the original exception will be stored in SftpException.InnerException property.

I wrote "always" because you can get ObjectDisposedException or ArgumentException, but those are obvious.

We also try to map well known socket errors to a human readable messages. E.g. socket error code 11001 = "No such host is known."
However, you can always access the inner SocketException and read the additional related socket error data for yourself.

Now, to the issue of the log showing errors, but no error is thrown on the client and the file is being uploaded successfully (if I understand it correctly).

The error is probably caused at the server side only, after the file upload is finished and the server and client did not communicate properly to close the socket.

Can you please try it with the latest version of Rebex Tiny SFTP Server?
If the issue is still present, can you please try it with the latest version of Rebex client as well?

To diagnose the issue, we would need logs from both sides (of the same session). If you want us to analyze the issue, please create VERBOSE log on both sides and send it to support@rebex.net, so we can see what was happening on both client and server (which commands followed by which ones with timestamps).

by (220 points)
As you said from SFTP client class we will always throw only SFTPException. Is this true even if we use FileTransferClient class for Sftp operations?

Similarly if we make FTP connections using FileTransferClient class will we always get only FtpException having SocketException (or any other exception) in InnerException property?

If above statements are true and we have SocketException in InnerException property then will eFTP.Status == FtpExceptionStatus.ProtocolError and eSFTP.Status == FtpExceptionStatus.ProtocolError be true or false?
by (70.4k points)
Yes, in FileTransferClient class you will always get SftpException when using SFTP protocol, and FtpException when using FTP protocol.

No, Status == ProtocolError will be set only in cases a protocol error appears e.g. "File not found" or "Access denied" etc.
For socket exceptions you should get Status == SocketError.