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

I've responded by an email.
Simpuhl

Script and Gui will both randomly stop working and error and then eventually just work again. Was the tracelog able to give you any details?
Guest

I attached the log via zip file.

I appreciate any help/advise
Simpuhl

See attached
Simpuhl

I am trying to attach the trace but it says its too large.. anyway I can send this over to you?
Simpuhl

Maximum attachment is 3, tried to attach trace log separately but file size is too large.
Simpuhl

Ok, so the script stopped working and I ran the DEBUG version of the GUI. These are the errors I get when trying to upload a file. Once the error happens, it happens in both GUI and PowerShell script. No idea what causes it...

3 Screenshots and trace log have been attached.

I appreciate any help
martin

Simpuhl wrote:

I also noticed the file will hang in the GUI also once the problem starts. So basically even if I manually upload it will show those same errors in the GUI version. If it happens again on this new server I'll try to take some screenshots.

So use the debug version for the GUI.
Simpuhl

Thank you,

I may not get another chance to test this as I already moved the scripts to another server. I will run the debug and email the zipped trace file if I manage to reproduce it. I am working with production files and when they are uploaded or downloaded a bunch of things happen after that so it's hard for me to "test".

PS:

I also noticed the file will hang in the GUI also once the problem starts. So basically even if I manually upload it will show those same errors in the GUI version. If it happens again on this new server I'll try to take some screenshots.
martin

Thanks for your report.
I have sent you an email with a debug version of WinSCP to the address you have used to register on this forum.
Simpuhl

So I think its actually a Windows Server issue because the hang-up also occurs when manually moving the file using the WinSCP GUI. If I perform the action from another server it uploads without any issues. When it does let me drag it over, the script also works without hanging.

I am using the latest version of WinSCP.

Any idea
Simpuhl

PowerShell Script Hanging

Hello,

I put together a script that works fine, it's setup as a scheduled task but after X amount of runs it will randomly hang. Once the hanging starts, it continues until I reboot the server. I cannot figure out why. I can take the same script and run it on another PC and it works without any issue but will eventually hang the same way. I can't tell if its a bug with WinSCP, PowerShell, or the script. I feel like if the previous sessions aren't being disposed correctly or something? To be honest I have no clue. It just hangs in the task scheduler or if I run it manually.

Here is the part of the log that the script just get's stuck.

. 2020-09-10 08:00:20.356 Getting real path for '/'

> 2020-09-10 08:00:20.356 Type: SSH_FXP_REALPATH, Size: 10, Number: 272
< 2020-09-10 08:00:20.403 Type: SSH_FXP_NAME, Size: 49, Number: 272
. 2020-09-10 08:00:20.403 Real path is '/USERNAME'
. 2020-09-10 08:00:20.403 File: 'C:\WinSCP Scripts\Temp2\XXXXX.xml' [2020-09-09T20:37:08.500Z] [75239]
. 2020-09-10 08:00:20.403 Copying "C:\WinSCP Scripts\Temp2\XXXXX..xml" to remote directory started.
. 2020-09-10 08:00:20.403 Binary transfer mode selected.
. 2020-09-10 08:00:20.403 Opening remote file.
> 2020-09-10 08:00:20.403 Type: SSH_FXP_OPEN, Size: 62, Number: 515
< 2020-09-10 08:00:20.465 Type: SSH_FXP_HANDLE, Size: 33, Number: 515
> 2020-09-10 08:00:20.465 Type: SSH_FXP_WRITE, Size: 32813, Number: 1030
. 2020-09-10 08:00:20.465 2 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2020-09-10 08:00:20.465 Type: SSH_FXP_CLOSE, Size: 33, Number: 1796
> 2020-09-10 08:00:20.465 Type: SSH_FXP_SETSTAT, Size: 58, Number: 777
. 2020-09-10 08:00:36.870 Waiting for data timed out, asking user what to do.
. 2020-09-10 08:00:36.870 Asking user:
. 2020-09-10 08:00:36.870 **Host is not communicating for 15 seconds.
. 2020-09-10 08:00:36.870
. 2020-09-10 08:00:36.870 Wait for another 15 seconds?** ()
< 2020-09-10 08:00:36.870 Script: Host is not communicating for more than 15 seconds.
< 2020-09-10 08:00:36.870 Still waiting...
< 2020-09-10 08:00:36.870 Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
< 2020-09-10 08:00:36.870 Warning: Aborting this operation will close connection!
. 2020-09-10 08:00:39.949 Data has arrived, closing query to user.
. 2020-09-10 08:00:39.949 Network error: Software caused connection abort
. 2020-09-10 08:00:39.949 Connection was lost, asking what to do.
. 2020-09-10 08:00:39.949 Asking user:
. 2020-09-10 08:00:39.949 Network error: Software caused connection abort ()
< 2020-09-10 08:00:39.949 Script: Network error: Software caused connection abort


The task errors with
Task Scheduler did not launch task "\Script" because instance "{654b6dbf-fd19-4a8c-8ce5-7b42590d11e6}" of the same task is already running.

Here is the script, I removed any identifying info

# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
 
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "xxxx.com"
    UserName = "XXXXXXSFTP"
    SshHostKeyFingerprint = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    SshPrivateKeyPath = "C:\Program Files (x86)\WinSCP\SSH Key\XXXXXXXX\XXXXXXXXXXXKey.ppk"
}
 
    $remotePath = "/"
    $localPath = "C:\WinSCP Scripts\XXXXXXXXXXXX\Temp2\*"
 
$uploadSession = New-Object WinSCP.Session
$uploadSession.SessionLogPath = "C:\WinSCP Scripts\XXXXXXXXXXXXt\TEST-Upload.log"
try
{
    # Connect
    $uploadSession.Open($sessionOptions)
 
    # Upload files
    $transferOptions = New-Object WinSCP.TransferOptions
    $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
    $transferOptions.OverwriteMode = [WinSCP.OverwriteMode]::Overwrite
 
    #Upload Files - localPath, remotePath, remove (true, deletes source local file(s) after a successful transfer)
    $transferResult = $uploadSession.PutFiles($localPath, $remotePath, $False, $transferOptions)
 
    # Print results
    foreach ($transfer in $transferResult.Transfers){
    Write-Host ("Upload of {0} succeeded" -f $transfer.FileName)
    #Copy-Item $transfer.FileName -Destination "E:\XXXXXXXXXXXXXXXXXXX"
    #Move-Item $transfer.FileName -Destination "\\XXXXXXXXXXXXX\Archive"
    $transferResult | Out-File "C:\WinSCP Scripts\XXXXXXXXXXXX\TEST-TransferResult.log"
    $transferResult.Transfers | Out-File "C:\WinSCP Scripts\XXXXXXXXXXXX\TEST-Transfers.log"
 
    # Throw on any error
    $transferResult.Check()
}
finally
{
    $uploadSession.Dispose()
}
    exit 0
catch
{
    Write-Host "Error: $($_.Exception.Message)"
    exit 1
}