Reputation: 726
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.
Upvotes: 1
Views: 2497
Reputation: 726
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.
Upvotes: 7