Post a reply

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

So please collect the logs for us.
Guest

Currently, I didn't have log files.
But, the issue is after transferring 1 gb the file transfer is starting from beginning and and again got interrupted and again starting from beginning and this process gets continues while using PowerShell script.
I have included
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off

Because, I don't want .filepart extension while transferring.
I have included this as well.
$sessionOptions.AddRawSettings("SendBuf","0")

Error messages I am getting in between for several times:

  1. Host is not communicating for more than 15 seconds. Host is not communicating
    Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
    Warning: Aborting this operation will close connection!

    But, already I have set this option to 0

  2. Remote side sent disconnect message type 11 (by application): "Idle connection"
    Authentication log (see session log for details): Using username .
    Authentication failed.


While transferring with GUI the file is transferring successfully. So, is there any option to fix this issue?
martin

Re: I am getting the same issue while uploading the files to SFTP.

@user123@: Please post session log files from both GUI and PowerShell showing transfer of the same file with different results.
user123@

I am getting the same issue while uploading the files to SFTP.

While running PowerShell script to transfer files to winscp I am getting an error like for the files greater than 1 gb the transfer got stuck after reaching 1 gb and again starting from beginning. How to resolve this issue?
But while uploading manually it is transferring.
In GUI I have seen the Endurance option. So, Is there any setting for automatic reconnect in PowerShell.
Woojo01

Reconnect and Resume

I am using PowerShell with the .NET assembly to obtain a 7G file on a daily basis. There are occasional times where the download is interrupted for various reasons of which the supplier has not been able to identify. I have used a for loop to execute the transfer multiple times after a failure. However, it seems the transfer always starts the from the beginning of the file on each iteration. This is very time consuming especially if the the transfer aborts 45 minutes into the download and starts from the beginning again. I do know the server supports resuming a download.

Am I missing something in the session options to enable an automatic reconnect and resuming a download where it left off?
Function Get-SupplierFtpFile
{
    [CmdletBinding()]
    Param(
        [Parameter(Position=0, Mandatory=$True)]
        [String]$RemotePath,
        [Parameter(Position=1, Mandatory=$True)]
        [String]$LocalPath,
        [Parameter(Position=4, Mandatory=$false)]
        [int]$Iterations = 36,
        [Parameter(Position=5, Mandatory=$false)]
        [int]$WaitSeconds = 300
    )
 
    Try
    {
        [Void][System.Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\WinSCP\WinSCP.dll")
        $FileName = [System.IO.Path]::GetFileName($RemotePath)
        # Setup session options
        $sessionOptions = New-Object WinSCP.SessionOptions
        $sessionOptions.Protocol = [WinSCP.Protocol]::Ftp
        $sessionOptions.FtpMode = [WinSCP.FtpMode]::Passive
        $sessionOptions.HostName = "ftp4.xxxxxxxx.com"
        $sessionOptions.UserName = "Username"
        $sessionOptions.Password = "pa$$word"
        $sessionOptions.PortNumber = 990
        $sessionOptions.FtpSecure = [WinSCP.FtpSecure]::Implicit
        $sessionOptions.SslHostCertificateFingerprint = "99:98:97:96:19:2f:dd:cc:aa:ff:89:78:77:66:76:75:74:73:72:71"
        # Connect
        $session = New-Object WinSCP.Session
        $session.SessionLogPath = "D:\Logs\GetFTP\$(Get-Date -Format "yyyyMMddHHmm").FTPlog.txt"
        $session.Open($sessionOptions)
 
        Try
        {
            For([int]$x = 1;$x -le $Iterations;$x += 1)
            {
                Write-EventLog -LogName ScriptEvents -Source PowerShellITG `
                    -Message "Supplier refresh: Download started." `
                    -EventId 1001 -EntryType Information
 
                Try
                {
                    $session.GetFiles($remotePath,$localPath).Check()
                    Break 
                }
                Catch
                {
                    Write-Warning $_.Exception.Message
                    Write-EventLog -LogName ScriptEvents -Source PowerShellITG `
                        -Message "Supplier refresh: Download aborted $x times. Retry in 5 minutes." `
                        -EventId 1002 -EntryType Warning
                }
                Start-Sleep -Seconds $WaitSeconds
 
            }
            If($x -ge $Iterations)
            {
                Throw "Excessive time waiting for remote file access."
            }
           
            Get-Item $localPath -ErrorVariable ERR -ErrorAction SilentlyContinue | Out-Null
            If($ERR)
            {
                Throw  $ERR.Message
            }
            Return $localPath
        }
        Catch
        {
            Throw $_.Exception
        }
    }
    Finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
    Return
}