All the clients use the same ConnectionInfo object to connect.
The following exception occurs either on Connect, or RunCommand, but mostly on Connect.
Renci.SshClient.Common.SshException: Message type 52 is not valid.
at Renci.SshClient.Session.WaitHandle(WaitHandle waitHandle)
at Renci.SshClient.PasswordConnectionInfo.OnAuthenticate()
at Renci.SshClient.ConnectionInfo.Authenticate(Session session)
at Renci.SshClient.Session.Connect()
at Renci.SshClient.BaseClient.Connect()
at upresources.LinuxSSH.Process(Object sender, DoWorkEventArgs e)
I have seen this behaviour with the max number of threads set to 3, but that was in debug-mode in VS 2010.
Please tell me if there's additional information I can provide.
Comments: ** Comment from web user: TobiaszJason **
We are running into this issue. The following sample code demonstrates the "Message type 52 is not valid" use case. You might have to run this a couple of times to see the error, but it does happen. This issue only occurs when using ConnectionInfo.
```
using System;
using System.Threading;
using System.Threading.Tasks;
using Renci.SshNet;
namespace ConsoleApplication8
{
internal class Program
{
private static void DoWork(
ConnectionInfo connectionInfo,
int threadNumber)
{
SftpClient ftp = new SftpClient(connectionInfo);
ftp.OperationTimeout = TimeSpan.FromMinutes(1);
int attempts = 0;
int maxAttempts = 3;
Console.WriteLine("Connecting to ftp. Thread: " + threadNumber + ".");
do
{
try
{
ftp.Connect();
}
catch (Exception exception)
{
Console.WriteLine("Error connecting to host. Thread: " + threadNumber + "." + Environment.NewLine + exception.Message);
}
if (!ftp.IsConnected)
{
Console.WriteLine("Error connecting to host. Thread: " + threadNumber + ". Attempting to connect again.");
}
else
{
Console.WriteLine("Successfully connected to server. Thread: " + threadNumber + ".");
break;
}
Thread.Sleep(500);
attempts++;
} while (attempts < maxAttempts);
}
private static void Main(string[] args)
{
string host = "x.x.x.x";
int port = 22;
string userName = "user";
string password = "password";
ConnectionInfo connectionInfo = new ConnectionInfo(
host,
port,
userName,
new AuthenticationMethod[]
{
new PasswordAuthenticationMethod(
userName,
password)
});
Parallel.For(0, 100, i =>
{
Thread thread = new Thread(() => DoWork(connectionInfo, i));
thread.Start();
});
Console.ReadLine();
}
}
}
```