Renci.SSHnet.Sftp超时错误
Renci.SSHnet.Sftp Timeout error
我正在尝试使用 Renci.SShnet.sftp 库连接到 ftp 服务器。
但是当我调用 sftp.Connect() 方法时,我收到以下错误消息:
"Socket read operation has timed out after 30000 milliseconds."。
我在 Visual Studio 2017 年使用 Visual Basic .Net。
我的代码如下:
Public Function SendFile(ByVal localFilePath As String, ByVal remotePath As String, ByRef errorReturnMessage As String) As Boolean
errorReturnMessage = ""
Try
Dim test As New Renci.SshNet.SftpClient(serverName, portNumber, userName, passWord)
test.Connect() '<==== ERROR HERE ======
test.ChangeDirectory(remotePath)
Dim str As IO.Stream
str = IO.File.OpenRead(localPathFile)
Dim result As Renci.SshNet.Sftp.SftpUploadAsyncResult = test.BeginUploadFile(str, remotePath)
Do While True
If result.IsCompleted Then
Exit Do
End If
Loop
Return True
Catch ex As Exception
errorReturnMessage = ex.Message
Return False
End Try
End Function
我正在尝试连接以上传文件。
谢谢你的帮助。
此致,
丹尼尔
感谢所有试图帮助我的人。
我知道 ftp 和 sFtp 是不同的。抱歉,我在 7 月 16 日在 11:35 写评论时犯了错误。
但是,解决方案是使用 winSCP API 而不是 Renci。
这比 Renci 容易得多,而且工作正常。
最好的问候...
我正在尝试使用 Renci.SShnet.sftp 库连接到 ftp 服务器。 但是当我调用 sftp.Connect() 方法时,我收到以下错误消息: "Socket read operation has timed out after 30000 milliseconds."。 我在 Visual Studio 2017 年使用 Visual Basic .Net。
我的代码如下:
Public Function SendFile(ByVal localFilePath As String, ByVal remotePath As String, ByRef errorReturnMessage As String) As Boolean
errorReturnMessage = ""
Try
Dim test As New Renci.SshNet.SftpClient(serverName, portNumber, userName, passWord)
test.Connect() '<==== ERROR HERE ======
test.ChangeDirectory(remotePath)
Dim str As IO.Stream
str = IO.File.OpenRead(localPathFile)
Dim result As Renci.SshNet.Sftp.SftpUploadAsyncResult = test.BeginUploadFile(str, remotePath)
Do While True
If result.IsCompleted Then
Exit Do
End If
Loop
Return True
Catch ex As Exception
errorReturnMessage = ex.Message
Return False
End Try
End Function
我正在尝试连接以上传文件。 谢谢你的帮助。
此致, 丹尼尔
感谢所有试图帮助我的人。 我知道 ftp 和 sFtp 是不同的。抱歉,我在 7 月 16 日在 11:35 写评论时犯了错误。 但是,解决方案是使用 winSCP API 而不是 Renci。 这比 Renci 容易得多,而且工作正常。 最好的问候...