【发布时间】:2019-04-17 20:22:18
【问题描述】:
多年来,以下代码一直有效。然后在 4 月 11 日,它停止了。我在 Visual Studio 中注意到 SSH.NET 包已过期的警告,因此我更新了包...仍然无法正常工作。
Protected Sub FTPUpload(ByVal fileToBeUploaded As String, uploadedFilename As String)
Try
Using sftp As New SftpClient(sFtpServer, sFtpCreditUser, sFtpCreditPW)
sftp.Connect()
Dim upFile As Stream = File.OpenRead(fileToBeUploaded)
sftp.UploadFile(upFile, uploadedFilename)
upFile.Close()
sftp.Disconnect()
End Using
Catch ex As Exception
MsgBox(ex.Message & Chr(13) & Chr(10) & uploadedFilename)
End Try
End Sub
抛出异常:
Renci.SshNet.dll 中的 Renci.SshNet.Common.SshConnectionException
Renci.SshNet.Common.SshConnectionException:已建立的连接被主机中的软件中止。
在 Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle)
在 Renci.SshNet.Session.Connect()
在 Renci.SshNet.BaseClient.Connect()
在 C:\Data\vb.net\InvManager2.3\InvManager\Main.vb:line 562 中的 InvManager.Main.FTPUpload(String fileToBeUploaded, String uploadFilename)
已验证凭据在服务器端仍然有效。
FileZilla 日志显示从运行主题 VB 代码的同一 Windows 机器到服务器的 SFTP 连接:
Status: Connecting to server.com...
Response: fzSftp started, protocol_version=8
Command: open "user@server.com" 22
Command: Pass: ******
Status: Connected to server.com
Status: Retrieving directory listing...
Command: pwd
Response: Current directory is: "/home/server"
Command: ls
Status: Listing directory /home/server
Status: Directory listing of "/home/server" successful
Status: Disconnected from server
希望能帮助您再次正常工作。
【问题讨论】:
标签: .net vb.net ssh sftp ssh.net