Low level logging ?

Jan 24, 2011 at 3:59 PM

Hi Oleg,

Yes it is Ted again! 

I am having another issue with my client's CoreFTP server ... one that I believe is their issue.  But I need to prove it.

I am using the SSH.NET function SftpClient.ListDirectory("/path") to get a list of all of the files in "/path".  However, sometimes, I am getting a list from a completely different path!

My question to you : is there a way to log the exact conversation between SSH.NET and the SFTP server?  I would like to see every low level command that SSH.NET sends, and the exact response that the SFTP server replies with.  This would prove without a doubt that the problem is on the server.

Thanks,

Ted.

Coordinator
Jan 24, 2011 at 5:13 PM

Hi Ted,

 

I was thinking about hardcoding some logging, but I was always removing it from the code once I was done with implementing specific feature, cause I otherwise I would get too much of debug information printed out.

 

To track this issue you can put logging statements into GetCanonicalPath function in SftpSession class.

 

This function is called every time it needs to resolve the path, this is what I did to fix your issue.

Or if you need to check ListDirectory function only, you can put logging into BeginListDirectory function, right after GetCanonicalPath function is called, since this is the path that will be passed to the server for execution. For example it can look like this:

            var fullPath = this._sftpSession.GetCanonicalPath(path);
            Debug.WriteLine(fullPath);

Let me know if you have any further issues.

 

Thanks,

Oleg

Jan 25, 2011 at 10:21 PM
Edited Jan 25, 2011 at 10:22 PM

Thanks Oleg.

 

I ended up outputting the contents of "messageData" at the top of Session.SendMessage(), and the contents of "messagePayload" at the bottom of Session.ReceiveMessage().

 

I was able to prove that the fault is on the client's CoreFTP server .... when SSH.NET sends the SSH_FXP_REALPATH packet, the server responds with an SSH_FXP_NAME packet that sometimes contained the wrong path!   At the highest level ... if my program does   sftpClient.ListDirectory("/path/to/my/files")   , I expect that the result will contain files in that directory.  I was sometimes getting files from a completely different directory!

 

The server's signature is "SSH-2.0-CoreFTP-0.1.2", which is an older version.  I do not know if this problem has been fixed in newer versions of CoreFTP -- my client is going to upgrade and possibly file a bug report with CoreFTP.  In the meantime, as a workaround, I am checking the SftpFile.FullName to make sure that the file came from the correct directory, before I process the file.

 

Thanks,

Ted.