Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

DeckStar

Re: Timeout and transfer options appear to be ignored in WinSCP for PowerShell

Thank you immensely. Annoying that it was something so simple.
DecksStar

Timeout and transfer options appear to be ignored in WinSCP for PowerShell

Hey Team,

Versions: WinSCP Version 5.17.10 (Build 11087) (OS 10.0.14393 - Windows Server 2016 Standard)

So the main issue is that we are having disconnections between my end (source) and the client (destination). We constantly see this message in the logs
. 2023-08-29 01:28:51.789 Waiting for dispatching send buffer timed out, asking user what to do.
. 2023-08-29 01:28:51.789 Asking user:
. 2023-08-29 01:28:51.789 **Host is not communicating for 15 seconds.
. 2023-08-29 01:28:51.789
. 2023-08-29 01:28:51.789 Wait for another 15 seconds?** ()
< 2023-08-29 01:28:51.789 Script: Host is not communicating for more than 15 seconds.
< 2023-08-29 01:28:51.789 Still waiting...
< 2023-08-29 01:28:51.789 Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
< 2023-08-29 01:28:51.789 Warning: Aborting this operation will close connection!
. 2023-08-29 01:29:52.541 Attempt to close connection due to fatal exception:
* 2023-08-29 01:29:52.541 **Terminated by user.**
. 2023-08-29 01:29:52.541 Closing connection.
. 2023-08-29 01:29:52.541 Sending special code: 1
. 2023-08-29 01:29:53.081 Connection was lost, asking what to do.
. 2023-08-29 01:29:53.081 Asking user:
. 2023-08-29 01:29:53.081 **Terminated by user.** ()
< 2023-08-29 01:29:53.081 Script: Terminated by user.
< 2023-08-29 01:29:58.092 Script: Searching for host...
. 2023-08-29 01:29:58.092 Looking up host "100.88.104.4" for SSH connection
. 2023-08-29 01:29:58.092 Connecting to 100.88.104.4 port 22
< 2023-08-29 01:29:58.108 Script: Connecting to host...


I tried to extend the timeout from 15 seconds with this line
$session.Timeout = New-TimeSpan -Seconds 150

And I've added the transfer options for turning off the optimize buffer size, but that seems to be ignored as well (based on the message above in the log)
$sessionOptions.AddRawSettings("AuthKI", "0")
$sessionOptions.AddRawSettings("AuthKIPassword", "0")
$sessionOptions.AddRawSettings("PingType", "1") # Enable KeepAlives to help prevent connection drops
$sessionOptions.AddRawSettings("SendBuf", "0") # Disable Optimize Buffer Size, as timeouts are occurring and it recommends this may help
$sessionOptions.AddRawSettings("SshSimple", "0") # Needed for the above

But the log file shows that the timeout isn't working
> 2023-08-29 01:15:37.156 Script: open sftp://vodafone-verint-staging%40mbie.external.sftp:***@100.88.104.4 -hostkey="[REDACTED]" -privatekey="D:\Archiver Extract\Cert\New Keys 25_02_2021\sft-privatekey.ppk" -timeout=15 -passphrase=*** -rawsettings AuthKI="0" AuthKIPassword="0" PingType="1" SendBuf="0" SshSimple="0" 

I'll attach the WinSCP code I have in my script, and a session log as well.