WinSCP PowerShell Timeout Errors

Advertisement

ccutting
Joined:
Posts:
1
Location:
Massachusetts

WinSCP PowerShell Timeout Errors

Hi,

We've been periodically receiving the following error message in our WinSCP log. The WinSCP executable is being called from a PowerShell script. This error seems to show up periodically and can usually be re-run. Does anyone have an idea why this might be happening
. 2022-03-16 13:46:04.458 Connection was lost, asking what to do.
* 2022-03-16 13:46:04.458 Timeout detected. (control connection)
. 2022-03-16 13:46:04.458 Asking user:
. 2022-03-16 13:46:04.458 Error transferring file *** ("Copying files to remote side failed.","Timeout detected. (control connection)")
< 2022-03-16 13:46:04.458 Script: Error transferring file ***.
< 2022-03-16 13:46:04.458 Script: Copying files to remote side failed.
We also get the following exception from our PowerShell script:
Exception calling "Check" with "0" argument(s): "Error transferring file ***. Copying files to remote side failed. Timeout detected. (control connection)"
The following is the PowerShell script:
$session_options = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::ftp
    HostName = ***
    UserName = ***
    SecurePassword = ***
}
 
try{
        # Create logging file
        if($ftp_log){
            $session.SessionLogPath = ***
        }
        $session_options.Timeout = New-TimeSpan -Seconds 30
        # Connect
        $session.Open($session_options)
 
        # Upload files
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
 
        $transferResult =
            $session.PutFiles($local_directory, $remote_directory, $False, $transferOptions)
 
        # Throw on any error
        $transferResult.Check()
 
        # Print results
        foreach ($transfer in $transferResult.Transfers)
        {
            Write_Log -message "Uploaded $($transfer.FileName)" -severity 1 -smtp_enabled $false
            $upload_log+="<br>Upload of $($transfer.FileName) succeeded!"
            
        }
        $return_val = $true
    }finally{
        # Disconnect, clean up
        $session.Dispose()
    }
}catch{
    return $false
}
$return_val = $true
return $return_val

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum