Hi Oleg,
I have to bother you again.
Found a new problem: after your fix in the isConnected method everything worked fine. But now I encountered a new problem. This is how to reproduce the problem: Starting 4 or more parallel downloads over one connection with <BeginDownload> and after everything is finished calling <EndDownload> on each (in the asyncCallback Method). If some of the files are not present on server side I get the "no such file" error. That's OK so far. But very often I get an error which is called "the safehandle has been closed" (Object disposed Exception) after <EndDownload>. The Problem is, that this exception occurs on downloads which are actually existent on the server.
So If you have 8 parallel Downloads with 4 existing and 4 non existing files you will get the following exceptions: 4 times "no such file", and 4 times Download OK. That’s how it should be. But sometimes you will get 6 times "no such file" PLUS 2 times"safe handle has been closed" and 2 times Download OK. So what happened to the 2 other files which were actually there? If the operation timeout is being set it even throws some “timeout” errors, even when the timeout is set to a ridiculous high amount (e.g. 60 seconds). The whole operations didn’t take 60 Seconds at all, so why it is throwing this exception?
Tried different servers again, it’s not related to them. Also tried latest Sourcecode.
Hope you understand what I'm trying to explain. A Stacktrace for better understanding:
Renci.SshNet.Common.SshException: Safe handle has been closed. ---> System.ObjectDisposedException: Safe handle has been closed. bei Renci.SshNet.Sftp.SubsystemSession.WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout) in C:\FTPDownloader\Renci.SshNet\SubsystemSession.cs:Zeile 165. bei Renci.SshNet.Sftp.SftpSession.RequestOpen(String path, Flags flags, Boolean nullOnError) in C:\FTPDownloader\Renci.SshNet\Sftp\SftpSession.cs:Zeile 298. bei Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, Action`1 downloadCallback) in C:\FTPDownloader\Renci.SshNet\SftpClient.cs:Zeile 1343. bei Renci.SshNet.SftpClient.BeginDownloadFile() in C:\FTPDownloader\Renci.SshNet\SftpClient.cs:Zeile 502. bei Renci.SshNet.Common.AsyncResult.EndInvoke() in C:\FTPDownloader\Renci.SshNet\Common\AsyncResult.cs:Zeile 93. bei Renci.SshNet.SftpClient.EndDownloadFile(IAsyncResult asyncResult) in C:\FTPDownloader\Renci.SshNet\SftpClient.cs:Zeile 536. bei PortalService.FTPDownloader.Data.cls_sFTPDownloader.DownloadComplete(SftpDownloadAsyncResult oState) in C:\FTPDownloader.Data\FTP Classes\cls_sFTPDownloader.vb:Zeile 123.