SftpClient.ListDirectory Bad packet length

Jun 18, 2012 at 6:22 PM

I'm trying to use the SftpClient to connect to a server, get a list of files, and download them.  I'm easily able to download files if I already know their names, but when my code calls ListDirectory, I get a "Bad Packet Length 55836" exception.  Here is the code:

 

ConnectionInfo connectionInfo = 
    new PasswordConnectionInfo(ftpServer, 8022, FtpLogin, FtpPw);

using (var client = new SftpClient(connectionInfo))
{
    client.Connect();

    var files = client.ListDirectory(".");
    foreach (var ftpfile in files)
    {
    }
}

 

All very straightforward.  What am I doing wrong?  When I connect to the server using CoreFTP, I see the following:

SSH-2.0-1.36 sshlib: GlobalScape  

client -> blowfish

server -> blowfish

xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx [substituted x's for hex digits]

ssh-dss

Sending password

PWD  

Current directory is '/'

Keep alive off...

Transferred 343 bytes in 0.008 seconds  

Regards,

Joe Henderson

Coordinator
Jun 18, 2012 at 6:37 PM

Hmm,

 

Usually bad packet exception occurs due to error in encryption or decryption, but since you saying it works if you want to download file that you already know it names, then it might be hard to track the problem.

 

Try to use different encryption and see if you still getting the problem.

 

Thanks,

Oleg

Jun 18, 2012 at 6:53 PM

Thanks for the response.  I tried all of these and got the same thing (or "not supported" for a few of them):

3des-cbc, aes128-cbc, aes192-cbc, aes256-cbc, aes128-ctr, aes192-ctr, aes256-ctr, blowfish-cbc and cast128-cbc

 

Regards,

Joe Henderson

Coordinator
Jun 18, 2012 at 6:56 PM

Hmm,

If its possible, try to create a test that I can run and see it happens, then I might be able to identify this problem, or if its possible and you have debug server that I can log into to test. I simply never heard of similar problem so not sure where to start  :(

 

Thanks,

Oleg

Jun 18, 2012 at 7:29 PM

If you can create a test program that reads its server name, port, login ID, and password from the app.config file, I can run it and give you the results.  Unfortunately, the server belongs to a wholesale sporting goods company that provides inventory and pricing information to my employer, and I can't give out the login info.

It's really strange that I have no problem calling the SftpClient.DownloadFile method if I already know the name of the file; I just can't get a directory listing.

Regards,

Joe