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
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