+1 vote
by (1.2k points)
edited by

Getting an exception System.InvalidOperationException:

Not enough data

With the following stack trace:

at Rebex.Net.JS.HH()
at Rebex.Net.JS.CH()
at Rebex.Net.SftpAttributes..ctor(JS C, Int32 L)
at Rebex.Net.NPW..ctor(Byte[] C, Int32 L, Int32 U, Encoding M, Int32 N)
at Rebex.Net.WDL.ZC(IS& C)
at Rebex.Net.WDL.ZC(UInt32 C, Boolean L)
at Rebex.Net.WDL.IC(IS C, UInt32 L, WQL U)
at Rebex.Net.WDL.HC(String C, Boolean L, Boolean U, Boolean M, UDL N, NDL& O, WQL J)
at Rebex.Net.Sftp.NRH(String C, Boolean L, Boolean U, Boolean M, WQL N)
at Rebex.Net.Sftp.WY(String C, WQL L)
at Rebex.Net.Sftp.DirectoryExists(String remotePath)

I'm rather clueless what might be the issue. Any hints?

Update:

Logs submitted to support.

Applies to: Rebex SFTP

1 Answer

+1 vote
by (70.2k points)
selected by
 
Best answer

The exception occurred during parsing of SftpAttributes, because data packet doesn't contain all required data.

To determine whether the issue is related to server response or client parser, please include the Verbose communication log. It can be done like this:

// connect to SFTP server
var client = new Sftp();
client.Connect(...);
client.Login(...);

// assign logger
client.LogWriter = new Rebex.FileLogWriter(@"C:\temp\sftp.log", Rebex.LogLevel.Verbose);

// perform operation
client.DirectoryExists("/data");
by (1.2k points)
edited by
Thanks, I've updated my posting.
by (70.2k points)
Thanks for the log file. Unfortunately, it is not common Rebex Verbose log. The format is different (you probably used your own logger?) but the main problem is that it doesn't contain raw data. It falsely outputs array as "buffer 'System.Byte[]', offset '0', length '57'."

I need to see the raw data received from the server. Please update your logger to outputs them or use built in Rebex.FileLogWriter.

Also please note, that using Verbose log during Login operation will outputs credentials in raw data. So I suggest you to assign logger after client.Login() call, or set LogWriter.Level to Info before login and set it back to Verbose after login.
Alternatively, delete Login data from log file manually.
by (1.2k points)
edited by
Thank you, Lukas. I've updated the above linked Pastebin. I did not find any credentials; although I'm sure they are included. Please tell me, when I can delete the Pastebin again. (I've renamed the actual host name in the log into "example.org").
by (70.2k points)
Thanks for the log. You can delete it. I will diagnose it and let you know ASAP.
by (70.2k points)
It seems that the issue is caused by a bug on server side, which we already workaround in version 2016 R6.1 (you are using 2016 R6):

  Added workaround for ProFTPd 1.3.6's mod_sftp which sends broken response when CREATETIME attribute has been requested. (for details see https://www.rebex.net/total-pack/history.aspx#2017R6.1)

Please upgrade to the latest version.
by (1.2k points)
Just updated and can confirm that this works! Awesome! Sorry for not trying the latest version immediately. I'll do better next time. Thanks for your quick help.
...