In our company we use .NET Assembly (winscpnet.dll) and WinScp utility to upload files on SFTP server. A connection with some of SFTP servers is very slow. So default 15 seconds connection timeout is not enough. We set different timeout in SessionOptions object and pass it to Session Open method, but it doesn't change the actual connection timeout (e.g. we set 5 mins timeout, call Open method and get timeout exception with message "Network error: Connection to [ip address] timed out." in about 15-20 seconds).
Open session call example:
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = host,
UserName = userName,
Password = password,
PortNumber = port,
SshHostKeyFingerprint = hostKeyFingerPrint,
Timeout = new TimeSpan(0, 5, 0)
};
_session.Open(sessionOptions);
In Log file we see that the following commands are executed and timeout parameter has the right value 300 seconds:
option batch on
option confirm off
option reconnecttime 120
open "sftp://username:***@10.11.178.20:22" -hostkey="ssh-ed25519 256 86:ff:cb:71:7a:e7:46:36:31:b2:26:01:a7:ec:a1:96" -timeout=300
Using WinSCP 5.11.1 on Windows 10 (also it is reproduced on Windows Server 2012 R2). Debug log file is attached.