This project is read-only.

Where are the errors ?

Oct 25, 2012 at 10:46 AM

Did not found a better subject title, sorry ^^

I was wondering why we do not have sftp server errors?

I try to explain. I use the library in one application that provide Sftp connections to users.
There is a case where the user cannot connect to the Sftp server because it doesn't have the right to access a directory, for example:

It should be logged into /usr/username, but for unknown reason it doesn't have access to /usr, so it cannot log into /usr/username.

If I use Filezilla I receive this message:
Connection closed by server with exitcode 128

With the library, it get stuck in

var index = EventWaitHandle.WaitAny(waitHandles, operationTimeout);


internal void WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout)

of SubsystemSession.cs.

The only way I found to get errors is to set the OperationTimeout to 2 seconds.
Which throw me a SshOperationTimeoutException(). The problem is that I'm not really fond of this, because this is no timeout, and I could timeout on other operation just because I may have set a value to low. 

I've tried to understand how it works and how to "unstuck" from WaitHandle, but I can't find anything.

Dec 27, 2012 at 11:38 PM



From what I managed to check, when an error occurs all I get is status code and message, which I wrapping into exception and throw it to the client.

The only thing I can think of is that maybe Filezilla can support higher SFTP version then 3 and that's why it can return more accurate information.


But lets say if that's true then you cant relay on it since what if you connect to the server that does not support higher version.


I will look into higher SFTP versions to see if that's an issue and could be resolved in the future.




Dec 28, 2012 at 1:19 AM


From what I could see is that later SFTP protocols support more error codes.

For example version 4 already have SSH_FX_WRITE_PROTECT status code which might be relevant in your case.

Unfortunately I only support version 3, at least at this point, since that what I found was mostly common.


I might be able to add support for more versions in the future as time permits.




Dec 28, 2012 at 10:26 AM

Ok, I can understand that.

But why does it get stuck in the method ? Is there any other solution (except the timeout?)

Dec 28, 2012 at 4:19 PM


Thats I will need to investigate I guess.


Since I am not a UNIX person I will need some help with that :(:(

How can I set up similar environment on my server?

What I mean is how to create a user who doesnt have access right to a folder when he logs in?

I created a user and then removed his right to access a folder but then what happened is when I logged in it went to the root folder and lists me root folders.

Or if you have test environment on your end that I can connect I could try that, you can send me info privately in this case.




Jan 4, 2013 at 10:44 AM
Edited Jan 4, 2013 at 10:59 AM

This happens only on MacOS X sftp servers, so I send you a private message with the information to connect and try it.

Jan 4, 2013 at 1:38 PM


Ok, So I found an issue.

What happens is that SFTP channel is being closed and I am not handling this situation in that case,

Will try to come up with a generic fix and will let you know.




Jan 4, 2013 at 1:55 PM



I just commited a fix for the problem you described.

I could not find an error message to display but now it does not hang but throws an exception saying that channel was closed.


Please let me know if you have suggestion for a better solution or this will work.