Topic "File transferring but .NET assembly timing out waiting to hear from host"

Author Message
Guest




I've using the .NET assembly in a PowerShell script to transfer a batch of files (1 - 4 of them at a time, generally) ranging in size from 10 KB to 500 KB. The script runs 3 times per day. Because of problems we were having the the transfers timing out, I turned off the 'Optimize connection buffer size', which seemed to help.

We've been having a run of interrupted transmissions for the past week. My hunch is that it's a problem with the connection on the other end. Would you look at the attached debug log and see what you think?

Thanks.

Johnny Lee
debug_20170906_060301.log (104.28 KB) Private file

Description: (none)

Advertisements
jlee
[View user's profile]

Joined: 2017-08-08
Posts: 6
Not sure why my post showed up as "Guest" as the author, since I was logged in when I wrote it. At any rate, I seem to be logged in now and hope my identity will register so I can get alerted of any responses.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27058
Location: Prague, Czechia
We need also a session log file.
Though this kind of problems are hard to debug even just using a log file.
jlee
[View user's profile]

Joined: 2017-08-08
Posts: 6
O.K. I've turned on session logging and will upload both logs the next time we have this problem again.

Thanks.

Johnny Lee
jlee
[View user's profile]

Joined: 2017-08-08
Posts: 6
Here is a zip file with the WINSCP debug log, the session log and logging that I do within the script. I appreciate any insight you can add into why the file uploads are failing now and then.

Thanks.
WINSCP_Log_Files.zip (12.47 KB) [Download]

Description: (none)

jlee
[View user's profile]

Joined: 2017-08-08
Posts: 6
And here is a copy of the main function within the PowerShell script that is using the .NET assembly. I've tried to implement the custom error handling logic you demonstrate here: https://winscp.net/eng/docs/library_example_recursive_download_custom_error_handling#powershell, but when the transmission fails, it is killing the job altogether.
MainUploadFunction.txt (3.94 KB) [Download]

Description: (none)

martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27058
Location: Prague, Czechia
Did you try setting a longer session timeout?

SessionOptions.Timeout:
https://winscp.net/eng/docs/library_sessionoptions#timeout
jlee
[View user's profile]

Joined: 2017-08-08
Posts: 6
Thanks for the suggestion. I've looked at that, but the documentation is a little confusing. Under the documentation for the Session class (https://winscp.net/eng/docs/library_session) the description for the Timeout property is "Maximal interval between two consecutive outputs from WinSCP console session, before TimeoutException is thrown. The default is one minute. It’s not recommended to change the value. For session/connection timeout, see SessionOptions.Timeout." And on the page for the SessionOptions, it says this: "Server response timeout. Defaults to 15 seconds." I don't understand the difference between the two, and which default is correct if they are referring to the same thing.

Also, what is the format for specifying a value in SessionOptions.Timeout? If 15 seconds is the default and I want to increase that to 30 seconds, would I specify the value as a literal string, or a numeral? If I was to increase it to more than 1 minute, how would that be formatted? "1:30", for example?

Thanks.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27058
Location: Prague, Czechia
I've pointed you to SessionOptions.Timeout, not Session.Timeout.

Also, as documented, it's of time TimeSpan, not string nor numeral.
jlee
[View user's profile]

Joined: 2017-08-08
Posts: 6
Thanks. That helps.

I had never used a TimeSpan in PowerShell before, but setting it up turned out to be pretty simple. Here's the code I used:

# Setup sFTPSession options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = $strTargetHostName
UserName = $strTargetUserName
Password = $strTargetPassword
SshHostKeyFingerprint = $strTargetFingerprint
Timeout = New-TimeSpan -Seconds 30 #increase from default of 15 seconds
}

The New-TimeSpan cmdlet can specify -Minutes, -Hours, etc. as well.

And it seems to have helped with the timeout issue I was having.

Much appreciated.
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