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

New Post: SftpClient never comes back in Connect

$
0
0
Hello,
I am using Renci.SshNet for SSH.
I am already using this for "sending to" (UploadFile()) and "pulling from" (DownloadFile()) files in the production system with no problems.
I am testing now sending a file to the Test site, and it is "hanging" there indefinitely after the Connect call..
I even tried to set a timeout (OperationTimeout), to no avail.

Here is the code
    bool uploadFile(String long_filename, String short_filename)
    {
       bool success = false;
       using (var sftp = new SftpClient(server, user, passw))
       {
         sftp.OperationTimeout = new TimeSpan(0, 0, 30); // 30 seconds

         // I see this.. 
         showMessage("Connecting..");

         sftp.Connect();

         // .. but don't see this..
         showMessage("Connected..");


         // Move to POLP-To-FDC directory when uploading..
         sftp.ChangeDirectory(@"/POLP-To-FDC/");

         showMessage("Moved to dir..");


         // upload the file 
         using (var filestream = File.OpenRead(long_filename))
         {
           sftp.UploadFile(filestream, short_filename, false);
           showMessage("Uploaded file..");
           success = true;
          }

          showMessage("isconnecting..");
          sftp.Disconnect();

      } // end using

      return success;
    }


Viewing all articles
Browse latest Browse all 1729

Trending Articles



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