0 votes
by (230 points)


I am in the process of implementing a rather special filesystem and have come across some things that would help with "how to implement" certain aspects:

  1. Is Serversession.Id unique? Does it ever get reused in the lifetime of a FileServer instance?

  2. In case I derive from FileNode/DirectoryNode - is FileServer and FileSystemProvider guaranteed to keep my special class in events/calls?

  3. Is it possible to send the client a specific message? How can such a message be received/retrieved using Rebex sftp client?

  4. What happens in case I throw an exception in a FileSystemProvider method (just as an example: CreateDirectory...)?

  5. What happens in case I throw an exception in a FileSystemNotifier event handler (just as an example: CopySurrogate...)?

  6. Is there a recommended way to handle error conditions in a custom file system provider - for example how to inform the client and/or end the current request and/or kill the session?

Thanks in advance.

Best Regards

Applies to: File Server

1 Answer

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

1) Session IDs get reused after 1048575 sessions have been established in a lifetime of a FileServer instance. However, it's guaranteed that no two separate sessions will use the same ID.

2) This kind of usage is a supported scenario and our VFS subsystem will behave accordingly - see the ZIP virtual file system provider sample that relies on custom nodes being kept.

3) Unfortunately, the SFTP protocol doesn't provide any standard mechanism for sending messages to SFTP clients. It's essentially a simple remote file system protocol, and messaging capabilities are outside of its scope. However, if both the client and the server side are under you control, you might achieve this by a custom extension - for example by using a special file for communication. Or you can open a custom SSH channel (within the same SSH session) and use that. But of course, this won't work with third-party SFTP clients.

4) and 5) The SFTP client will receive a generic SFTP error with an error code of SSH_FX_FAILURE and an error message of 'Internal server error.'. If you throw a FileSystemException exception, the client will get the supplied error message instead.

6) SFTP is essentially a simple remote file system protocol, so the only standard way to inform the client of an error is to fail an operation and supply an error message.

by (230 points)
Thank you very much - this helps alot.

One question though regarding #1:
Is the "Disconnected" event guaranteed to be called for any session that ends (independent of whether it ended gracefully or not) with its id present in the DisconnectedEventArgs.Session.Id?
by (146k points)
Yes. It should get called for all ended sessions, regardless the reason. An absence of 'Disconnected' event getting called would be a bug.