Re: Connection timed out
Thanks for sharing your solution.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
// Set up session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = _hostName,
UserName = _userName,
Password = _password,
SshHostKeyFingerprint = _sshHostKey,
};
using (Session session = new Session())
{
// Will continuously report progress of synchronization
session.FileTransferred += FileTransferred;
// Attempt to loop through opening the session three times.
int loop = 0;
while (loop < 3)
{
try
{
// Open session. Break out of loop if successful
session.Open(sessionOptions);
break;
}
catch (SessionRemoteException e)
{
//Increment the loop and wait 5 seconds. If three failed attempts, throw an exception
loop++;
if (loop >= 3) throw e;
Thread.Sleep(5000);
}
catch (Exception e)
{
// All other exceptions, pass e up to parent catch
throw e;
}
}
}