1

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?

4
  • I had a similar issue with WinSCP a few years ago which led to my discovery of the WinSCP forums where any of the threads are answered by the main developer himself.
    – Tyson
    Mar 17, 2015 at 13:43
  • Does it "hang" or does it keep re-trying to connect? Mar 17, 2015 at 14:29
  • @Martin Pikryl, wscp prompts Connecting to host and waits infinitely.
    – R. Nec
    Mar 17, 2015 at 14:45
  • Please include a WinSCP session log file. Mar 17, 2015 at 15:02

2 Answers 2

1

On you open command you can set a timeout parameter

-timeout=<sec>

Example:

open sftp://martin:[email protected]/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" -timeout=30
1

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.

Examples:

option batch abort
option reconnecttime 60
open sftp://[email protected]/ -timeout=15
2
  • When using option reconnectime 60 I get Unknown option 'reconnectime'.. Try instead using reconnecttime.
    – Arvo Bowen
    Aug 9, 2018 at 21:38
  • @ArvoBowen Thanks, I've corrected my answer. Aug 10, 2018 at 5:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .