sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.94k stars 927 forks source link

SshException: Can not skip back in messages #168

Open tomasaschan opened 7 years ago

tomasaschan commented 7 years ago

We're seeing a bunch of errors like this one in our production environment, but I can't reproduce it when running locally. Thus, it's pretty difficult to figure out where the faulting code is.

ERROR Renci.SshNet.Common.SshException: Can not skip back in messages.
   at Renci.SshNet.Sftp.SftpSession.RequestRead(Byte[] handle, UInt64 offset, UInt32 length)
   at Renci.SshNet.Sftp.SftpFileStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at <someone else's code>

Do you have any suggestions on what could cause these exceptions to be thrown?

We do have code like this:

contents.Flush(); // contents is an SftpFileStream
contents.Seek(0, SeekOrigin.Begin);

but that works fine when I'm debugging. Any help with either fixing this problem, or even reproducing it locally, is much appreciated.

drieseng commented 7 years ago

What SSH server are you using (name+version)?

tomasaschan commented 7 years ago

I don't know; it's a remote server hosted by a third party, and the status information given by e.g. FileZilla when connecting contains no such information.

I'm not an SFTP expert - is there some standard way to check?

drieseng commented 7 years ago

this page details how you can obtain information of the remote server.

would it be possible to temporarily grant me access to that server (provided it's a test server of course)?

tomasaschan commented 7 years ago

Ah, nice. A console app that runs that code prints this:

SSH-2.0-3.2.3 F-Secure SSH Windows NT Server

This only fails in production, so no - no way to give anyone access for troubleshooting. (And even if I wanted to, I don't have the authority to make it happen, as - again - this is a third party server we're using for an integration, so the server is out of our own control.)

drieseng commented 7 years ago

Could it be that you're using another SSH server in other environment? F-Secure 3.2.3 appears to be a very old version, so it may be a known issue in that release. Attachmate is now the owner of the F-Secure SSH product line, and any version below 5.3 is discontinued: http://support.attachmate.com/programs/lifecycle/version-status.html?fsecuressh