1

I use SSH.NET(2013.4.7 version) library for uploading files to SFTP server. Here is piece of my code:

using (var client = new SftpClient(host, port, username, password))
{
    client.Connect();
    ...
}

I get following error message on Connect() method execution: "System.InvalidOperationException: Server string is null or empty."

I have found small advice regarding this issue here: http://www.ipbalance.com/programming/ms-powershell/1098-powershell-how-to-use-sshnet-library-for-cisco-on-windows-7.html to use 'x.x.x.x' host format instead of x.x.x.x, but it doesn't help me.

Value of host variable is "153.112.49.198". port is 22. It works fine, when I use FileZilla tool with the same host, port, username and password.

Stack trace:

System.InvalidOperationException: Server string is null or empty.
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at [here is my method]

Any help will be appreciated.

7
  • Did you debug that? What is the content of host? Commented Aug 4, 2016 at 15:37
  • @RenéVogt, the question is edited Commented Aug 4, 2016 at 15:39
  • Can you connect using command-line ssh or PuTTY? What are the other variables? Commented Aug 4, 2016 at 17:26
  • Show us an exception callstack + What version of the library are you using? Commented Aug 4, 2016 at 18:55
  • @Jakuje, yes I can connect via FileZilla. Commented Aug 4, 2016 at 20:18

1 Answer 1

7

Finally, I have solved this problem. There was SFTP server setting “Max number of connections” with value “1” by default, so I was not able to connect, since FileZilla's connection was already created.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.