I've batch script that runs winscp with script, and sometimes WinSCP hangs when is "Connecting to host".
Is it possible to set timeout that WinSCP stops trying to connect and shuts it's self after x seconds when cannot connect?
On you open command you can set a timeout parameter
open sftp://martin:firstname.lastname@example.org/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" -timeout=30
A default timeout is 15 seconds. You can change it using the
-timeout switch of the
open command. Though in some cases, Windows does not respect the timeout and may use longer (or shorter).
When a connection fails (or times out), WinSCP will retry the connection. In the default "batch" mode, WinSCP will keep re-trying for up to 2 minutes. In an interactive mode, it keeps trying forever.
You can change the limit using the
option reconnecttime <sec> command.
option batch abort option reconnecttime 60 open sftp://email@example.com/ -timeout=15