Topic "Connection Error"

Author Message
as1981
[View user's profile]

Joined: 2015-04-18
Posts: 16
All,

I'm using the following code and most of the time it works really well:

Set scpsession = New WinSCPnet.session
Set scpsessionOptions = New WinSCPnet.sessionOptions
Set scptransferOptions = New WinSCPnet.transferOptions

Log "After session create"

With scpsessionOptions
Select Case UCase(strDetailList(0))
Case "FTP"
.Protocol = Protocol_Ftp
'Log "FTP protocol selected"
Case "SFTP"
.Protocol = Protocol_Sftp
'Log "SFTP protocol selected"
End Select
.HostName = strDetailList(1)
Log "Hostname set"
.UserName = strDetailList(2)
Log "Username set"
.Password = strDetailList(3)

'Log "Password set"
'.SessionLogPath = "c:\winscp.net"
'Log "Log path set"
.PortNumber = strDetailList(4)
Log "Port set"
End With

' Connect
scpsession.Open scpsessionOptions


Sometimes I get a connection error on the .password = strdetaillist(4) line. I don't understand why I would get a connection error because I don't think the connection is started until the line scpsession.Open scpsessionOptions?

Thanks

Andrew
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
You indeed cannot get an exception when setting the .Password. Show us the exception callstack.
_________________
Martin Prikryl
as1981
[View user's profile]

Joined: 2015-04-18
Posts: 16
Hello,

Thank you for the confirmation that it's not possible to get a connection error when setting the password.

Unfortunately our program log didn't capture the exception trace.

I think, maybe, the error was on scpsession.Open scpsessionOptions. I think it's possible to get a connection error from this operation? I think the correct way to capture this is with try/catch coding? I don't think the scpsession.open returns an error code in the same way as something like putfiles does?

Thanks

Andrew
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Yes the Session.Open throws an exception on error. Use the Catch clause to capture it in VB.NET.
Advertisements

You can post new topics in this forum






Search Site

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