Topic "winscp .net waiting for log update and dispatching events"

Author Message
olegur

Guest


I have issues with my script where it says "timeout waiting for winscp to respond" and i am clueless as to what it could be
using .net for powershell btw

Code:
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"

# Session.FileTransferred event handler
 
function FileTransferred
{
    param($e)
 
    if ($e.Error -eq $Null)
    {
        Write-Host ("Upload of {0} succeeded" -f $e.FileName)
    }
    else
    {
        Write-Host ("Upload of {0} failed: {1}" -f $e.FileName, $e.Error)
    }
 
    if ($e.Chmod -ne $Null)
    {
        if ($e.Chmod.Error -eq $Null)
        {
            Write-Host ("Permisions of {0} set to {1}" -f $e.Chmod.FileName, $e.Chmod.FilePermissions)
        }
        else
        {
            Write-Host ("Setting permissions of {0} failed: {1}" -f $e.Chmod.FileName, $e.Chmod.Error)
        }
 
    }
    else
    {
        Write-Host ("Permissions of {0} kept with their defaults" -f $e.Destination)
    }
 
    if ($e.Touch -ne $Null)
    {
        if ($e.Touch.Error -eq $Null)
        {
            Write-Host ("Timestamp of {0} set to {1}" -f $e.Touch.FileName, $e.Touch.LastWriteTime)
        }
        else
        {
            Write-Host ("Setting timestamp of {0} failed: {1}" -f $e.Touch.FileName, $e.Touch.Error)
        }
 
    }
    else
    {
        # This should never happen during "local to remote" synchronization
        Write-Host ("Timestamp of {0} kept with its default (current time)" -f $e.Destination)
    }
}

# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Ftp
    HostName = "FTPHOST"
    PortNumber = 21
    UserName = "FTPUSERNAME"
    Password = "FTPPASSWORD"
}

$session = New-Object WinSCP.Session

try
{
        # Will continuously report progress of synchronization
        $session.add_FileTransferred( { FileTransferred($_) } )
       
        #Logging
        $session.DebugLogPath ="C:\WinSCP\Log\winscp-debug.log"
        #$DateTime = Get-Date -format yyyy/MM/dd-HH.mm.ss
        #$session.SessionLogPath ="C:\WinSCP\log\$DateTime-WinSCP.log"

        # Connect
        $session.Open($sessionOptions)
 
        # Synchronize files
        $synchronizationResult = $session.SynchronizeDirectories(
            [WinSCP.SynchronizationMode]::Local, "\\LOCAL\felles\Timelapse", "/lerftp/", $False)
 
        # Throw on any error
        $synchronizationResult.Check()
}
finally
{
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
catch [Exception]
{
    Write-Host ("Error: {0}" -f $_.Exception.Message)
    exit 1
}



and i attached my debug log
winscp-debug.log (43.09 KB) [Download]

Description: (none)

martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
Did you try setting longer Session.Timeout?
https://winscp.net/eng/docs/library_session#timeout
olegur

Guest


tried timeout now and it seems to have fixed it, was also getting 0x1 error in task scheduler. Thanks Very Happy #lifesaver
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License