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

Re: Connection Timed out

A log for "However It works when I use the WinSCP client."
pmenage

Re: Connection Timed out

Sorry for the question but what do you mean by GUI log ?
martin

Re: Connection Timed out

A log from from a GUI too, please.
pmenage

Re: Connection Timed out

Please find attached the session log file. The source code is displayed below:

Private Sub BtnWinScpUpload_Click(sender As Object, e As System.EventArgs) Handles BtnWinScpUpload.Click

Dim sessionOptions As New SessionOptions
Dim tim As TimeSpan = TimeSpan.FromMinutes(1000)

Try

' Setup session options
sessionOptions.Protocol = Protocol.Sftp
sessionOptions.HostName = TextHostName.Text.ToString.Trim '"example.com"
sessionOptions.UserName = TextUserCode.Text.ToString.Trim '"user"
sessionOptions.Password = TextPassword.Text.ToString.Trim '"mypassword"
sessionOptions.SshHostKeyFingerprint = TextHostKeyFingerPrint.Text.ToString.Trim '"ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
sessionOptions.Timeout = tim

Using session As New WinSCP.Session
session.SessionLogPath = "C:\TestSftp\test\WinScp.log"


'if WinScp.exe is not in same path than WinScp.dll, then use the below line to point to WinScp.exe
'session.ExecutablePath = "C:\Download and Documentation\WinScp\winscp577automation\WinSCP.exe"

' Connect
session.Open(sessionOptions)

' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary

Dim transferResult As TransferOperationResult
'transferResult = session.PutFiles("d:\toupload\*", "/home/user/", False, transferOptions)
transferResult = session.PutFiles(TextLocalPath.Text.ToString.Trim & TextFileName.Text.ToString.Trim, TextRemotePath.Text.ToString.Trim, False, transferOptions)

' Throw on any error
transferResult.Check()

' Print results
For Each transfer In transferResult.Transfers
MessageBox.Show("Upload of file " & transfer.FileName & " succeeded")
Next

End Using

Catch ex As Exception
MessageBox.Show("BtnWinScpUpload_Click : " & ex.Message & vbCrLf & "Source :" & ex.Source & "Stack Trace : " & ex.StackTrace)
End Try

End Sub
martin

Re: Connection Timed out

Show us a session log file both from code (Session.SessionLogPath) and GUI.
pmenage

Connection Timed out

I am trying to connect to a sftp site to upload a file but I cannot even open the connection because I receive the following error message:
Network error connection to "xxxxxxxxx" timed out(my site is different)

However It works when I use the WinSCP client.

My code is as below:
Dim sessionOptions As New SessionOptions

Try

' Setup session options
If TextProtocol.Text.ToString.Trim = "Protocol.Sftp" Then
sessionOptions.Protocol = 1
End If

sessionOptions.HostName = TextHostName.Text.ToString.Trim '"example.com"
sessionOptions.UserName = TextUserCode.Text.ToString.Trim '"user"
sessionOptions.Password = TextPassword.Text.ToString.Trim '"mypassword"
sessionOptions.SshHostKeyFingerprint = TextHostKeyFingerPrint.Text.ToString.Trim '"ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"


Using session As New Session

' Connect
session.Open(sessionOptions)

' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary

Dim transferResult As TransferOperationResult
'transferResult = session.PutFiles("d:\toupload\*", "/home/user/", False, transferOptions)
transferResult = session.PutFiles(TextLocalPath.Text.ToString.Trim, TextRemotePath.Text.ToString.Trim, False, transferOptions)

' Throw on any error
transferResult.Check()

' Print results
For Each transfer In transferResult.Transfers
MessageBox.Show("Upload of file " & transfer.FileName & " succeeded")
Next
End Using

I copied the source code proposed on the WinScp site.

I would be most grateful if could tell me why there is this time out and how to avoid it.

Regards

Patrick