SSHClient: ForwardedPortLocal: memory issue
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- csharp
- 领域
- networking
调研方向
从 ConnectSSH 入口点以及报告中所示的重复创建 ForwardedPortLocal 开始。重现运行一整夜或重复调用的场景,然后跟踪端口转发的生命周期和释放行为;当重复连接不再显示内存使用量持续增加时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Hello,
I am using the following code below. I call this ConnectSSH() every 5 seconds (as a test to see how it performs)
After I let this run a night, i see that the used memory increased significantly, and it keeps rising.
After some investigation on my own, i notice that when I remove the "forwardedportlocal" object, (so I don't make such an object, and I obviously don't start it) Then there is no memory issue. The client is created, and then disposed cleanly.
I can see this happening the diagnostic tool of visual studio.
I already added portfwld.stop() and portfwld.dispose() together with of course SshClient.disconnect() and SshClient.dispose()
but that did not help.
I made a version in vb.net and also one in c#, but the results are the same.
I also Commented the connection to the database to show that this is not the issue.
I hope someone can give me some insight of what is happening, or perhaps what I am doing wrong?
class mySQLviaSHH
{
public void ConnectSSH()
{
using (var SSHClient = new SshClient("myhost", "administrator", "mypassword"))
{
try
{
// Console.WriteLine("Trying SSH connection...")
SSHClient.Connect();
if (SSHClient.IsConnected)
Console.WriteLine("SSH connection is active");
else
Console.WriteLine("SSH connection has failed");
Console.WriteLine("Trying port forwarding...");
var portFwld = new ForwardedPortLocal("127.0.0.1", "127.0.0.1", 3306);
SSHClient.AddForwardedPort(portFwld);
portFwld.Start();
if (portFwld.IsStarted)
Console.WriteLine("Port forwarded: {0}", portFwld.ToString());
else
Console.WriteLine("Port forwarding has failed.");
}
catch (SshException e)
{
Console.WriteLine("SSH client connection error: {0}", e.Message);
}
}
}
}
Public Sub ConnectSSH()
Using SSHClient = New SshClient("myhost", "administrator", "mypassword")
Try
Console.WriteLine("Trying SSH connection...")
SSHClient.Connect()
If SSHClient.IsConnected Then
Console.WriteLine("SSH connection is active")
Else
Console.WriteLine("SSH connection has failed")
End If
Console.WriteLine(vbCrLf & "Trying port forwarding...")
Dim portFwld = New ForwardedPortLocal("127.0.0.1", "127.0.0.1", 3306)
SSHClient.AddForwardedPort(portFwld)
portFwld.Start()
If portFwld.IsStarted Then
Console.WriteLine("Port forwarded: {0}", portFwld.ToString())
' 'Dim dbConnect As DBConnect = New DBConnect(portFwld.BoundHost, "wcs_sch", "root", "dbpassword", "3306")
' 'Dim ct = dbConnect.Count("wcs_msg_host")
' 'Console.WriteLine(ct.ToString())
Else
Console.WriteLine("Port forwarding has failed.")
End If
Catch e As SshException
Console.WriteLine("SSH client connection error: {0}", e.Message)
Catch e As System.Net.Sockets.SocketException
Console.WriteLine("Socket connection error: {0}", e.Message)
End Try
End Using
End Sub
- 主要语言
- C#
- 星标
- 4.4k
- 派生
- 993
- 平均合并
- 9 天 21 小时
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sshnet/SSH.NET 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 48/100
-
难度 3/5 1-2 天 新手友好度 67/100
-
难度 4/5 3-5 天 新手友好度 55/100
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
难度 2/5 1-3 小时 新手友好度 72/100
azurenoops/spin_agent#975 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
难度 2/5 1-3 小时 新手友好度 92/100
dotnet/AspNetCore.Docs#37699 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
SubtitleEdit/subtitleedit#15108 · 1 条评论 ·