tomohulk / WinSCP

WinSCP PowerShell Wrapper Module
GNU General Public License v3.0
151 stars 29 forks source link

[Question] Disable session reconnect completely? #128

Closed OCram85 closed 4 years ago

OCram85 commented 4 years ago

Is there a way to disable the auto reconnect feature like within the GUI?

image.png

tomohulk commented 4 years ago

I don't have a good way to test this right now, but you can try the -ReconnectTime parameter on the New-WinSCPSession cmdlet, just set it to 0.

OCram85 commented 4 years ago

Thanks, I will try it and let you know the results! 😄

OCram85 commented 4 years ago

So I tried disabling the reconnect with -ReconnectTime 0 and additionally adding a custom transfer option like this:

Send-WinSCPItem @ParamsSendItem -TransferOptions (
  New-WinSCPTransferOption -ResumeSupport (
    New-WinSCPTransferResumeSupport -State Off
  )
)

Unfortunately it doesn't work either 😢

tomohulk commented 4 years ago

can you try it on the WinSCP.Session object. Created with New-WinSCPSession? use the -ReconnectTime parameter. the object supports this.

https://winscp.net/eng/docs/library_session (see the ReconnectTime parameter)

Sets time limit in seconds to try reconnecting broken sessions. Default is 120 seconds. Use TimeSpan.MaxValue to remove any limit. The property has to be set before calling Open.

New-WinSCPSession -SessionOptions $sessionOptions -ReconnectTime [TimeSpan]::new(0)

schlabbe14 commented 4 years ago

these additional configurations could be set by using AddRawConfiguration:

$ParamsNewWinSCPSessionOption = @{
    Credential = $Credential
    Hostname   = $FTP
    Protocol   = 'Ftp'
    FtpMode    = 'Passive'
    Timeout    = [timespan]::FromMinutes(5)
 }
 $SessionOption = New-WinSCPSessionOption @ParamsNewWinSCPSessionOption
 $WinSCPSession = New-WinSCPSession -SessionOption $SessionOption
 $WinSCPSession.Close()
 $WinSCPSession.AddRawConfiguration('Interface\SessionReopenAuto',0)
 $WinSCPSession.AddRawConfiguration('Interface\SessionReopenIdle',0)
 $WinSCPSession.AddRawConfiguration('Interface\SessionReopenStall',0)
 $WinSCPSession.Open($SessionOption)
OCram85 commented 4 years ago

@tomohulk: Sorry for the delay! @schlabbe14 helped me out with this: It works now with customizing the RawConfiguration....

schlabbe14 commented 4 years ago

jip ;-)