Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Auto retry sync check when comparing FTP directory

What version of WinSCP are you using?

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
dylanmdestpern

Auto retry sync check when comparing FTP directory

I'm running a batch file (which is being called from Task Scheduler in Windows) that calls a synchronize remote command where the destination is the FTP directory:

Batch file:

@echo off

set TRIES=7
set INTERVAL=4
 
:retry
 
"c:\Program Files (x86)\WinSCP\WinSCP.com" /console /script="c:\Program Files (x86)\WinSCP\UploadScript.txt"
 
if %ERRORLEVEL% neq 0 (
   set /A TRIES=%TRIES%-1
   if %TRIES% gtr 1 (
       echo Failed, retrying in %INTERVAL% seconds...
       timeout /t %INTERVAL%
       goto retry
   ) else (
       echo Failed, aborting
       exit /b 1
   )
)
echo Success
exit /b 0


UploadScript.txt:

open bupload

option batch on
synchronize remote "c:\source" "\"
exit


Because the internet in the country is very unstable, the connection will drop for seconds at a time. And this will cause an error whilst the software is comparing the content in the file:
Comparing...

Local 'c:\source\2017-09-05' => Remote '\/2017-09-05'
Local 'c:\source\2017-09-06' => Remote '\/2017-09-06'
Local 'c:\source\2017-09-07' => Remote '\/2017-09-07'
Error listing directory '\/2017-09-07'.
Could not retrieve directory listing

Could not create socket.
(A)bort, (R)etry, (S)kip: Abort


As you can see it successfully receives the directory listing for the first few directories (2017-09-05 to 2017-09-06). But then it fails and automatically aborts at 2017-09-07. This happens randomly. If I run the app again it will fail at a different directory. Sometimes it doesn't even fail at all.

I would like the program to automatically try to retrieve the directory listing again if it fails because if it keeps trying it will eventually succeed (because the internet becomes stable).
My batch file has a work-around that detects if the program exits with an error and then restarts the app entirely (7 times) but this will then cause it to start comparing from the first directory again (leaving more room for connection errors to occur).

Is this possible?