Topic "Connection Timed out"

Author Message
pmenage
[View user's profile]

Joined: 2016-07-11
Posts: 3
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Show us a session log file both from code (Session.SessionLogPath) and GUI.
pmenage
[View user's profile]

Joined: 2016-07-11
Posts: 3
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
WinScp.log (3.8 KB) [Download]

Description: Session Log File

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
A log from from a GUI too, please.
pmenage
[View user's profile]

Joined: 2016-07-11
Posts: 3
Sorry for the question but what do you mean by GUI log ?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
A log for "However It works when I use the WinSCP client."
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