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

abd1111

Here's a snippet with the same settings where it tries listing the first directory and then just stops in another log:

> 2025-08-20 15:18:12.849 Script: ls -- "/1 xxxxx CLIENTS/xxxxxxxx/Sydney TPA/A-CAP/Client Folders/xxxxxxxx/"
. 2025-08-20 15:18:12.849 Retrieving directory listing...
> 2025-08-20 15:18:12.849 CWD /1 xxxx CLIENTS/xxxxxx/Sydney TPA/A-CAP/Client Folders/xxxxxxxxxxxx
. 2025-08-20 15:20:42.155 Timeout detected. (control connection)
. 2025-08-20 15:20:42.155 Could not retrieve directory listing.
. 2025-08-20 15:20:42.164 Retry interval expired, will not retry transfer
< 2025-08-20 15:20:42.171 Script: Lost connection.
< 2025-08-20 15:20:42.171 Timeout detected. (control connection)
< 2025-08-20 15:20:42.171 Could not retrieve directory listing.
< 2025-08-20 15:20:42.171 Error listing directory '/1 xxxxx CLIENTS/xxxxx/Sydney TPA/A-CAP/Client Folders/xxxxxxx'.
abd1111

Wondering, also, if
session.ReconnectTime

needs to be called in order to work, or is it just on by default? I'd love something that could force re-connect. Thanks. Not terribly Powershell savvy.
abd1111

Log included - Keep disconnecting from FTP

Hello! I have had this issue before, and it happens randomly (especially when I need to do some file uploads). I will often get a timeout or something like:
"Exception calling "Open" with 

"1" argument(s): "Connection failed.
Timeout detected. (control connection)
Connection failed.""


Here's a snippet of the setup:
    Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"


    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Ftp
        HostName = "usxxxxxxxxxx.sharefileftp.com"
        UserName = "xxxxxxxxxxx"
        Password = $plainPass # Read in as a secure string
        FtpSecure = [WinSCP.FtpSecure]::Implicit
        Timeout = New-TimeSpan -Seconds 150

    }
   
    $session = New-Object WinSCP.Session
    Remove-Item $sessionLog_File
    $session.SessionLogPath = $sessionLog_File
    $session.Open($sessionOptions)


All the rest of the code is just looping through directories and doing a bunch of PutFiles. It's a 50/50 shot, usually that it won't time out halfway through my file upload list or just after logging in.

I have already tried adding something like:
$session.Timeout = New-TimeSpan -Seconds 500

below the $sessions.Open, but I don't think anything has exactly worked better.

Thanks!