Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: SFTP parallel downloads with one connection - Exception (not threadsafe?)

$
0
0

 

Hi,

the exception shows up random and is hard to provocate.
EnsureConnection seems to be the problem.


Exception:

Renci.SshNet.Common.SshConnectionException: Client not connected.
   bei Renci.SshNet.BaseClient.EnsureConnection()
   bei Renci.SshNet.SftpClient.BeginDownloadFile(String path, Stream output, AsyncCallback asyncCallback, Object state, Action`1 downloadCallback)
   bei ConsoleApplication1.Module1.Main()


Code:
 
            oSFTPClient = New Renci.SshNet.SftpClient("127.0.0.1", "user", "pass")
            oSFTPClient.Connect()

            oQ = New Queue(Of IO.Stream)()

            For i AsInteger = 1 To iCount
                oQ.Enqueue(New IO.FileStream("c:\test\test"& i & ".dat", IO.FileMode.CreateNew))
            NextIf oSFTPClient.IsConnected ThenFor i AsInteger = 1 To iCount
                    Dim oStream As IO.Stream = oQ.Dequeue()
                    oSFTPClient.BeginDownloadFile("d:\file.dat", oStream, AddressOf DownloadDone, Nothing)
                NextEndIfCatch ex As Exception
            Debug.WriteLine(ex.ToString)
        EndTry


Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>