SSHClient: ForwardedPortLocal: memory issue

Abierto
#775 6 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
networking

Línea de trabajo

Comienza con el punto de entrada ConnectSSH y la creación repetida de ForwardedPortLocal que se muestra en el informe. Reproduce el escenario durante toda la noche o con llamadas repetidas y, a continuación, sigue el ciclo de vida del reenvío de puertos y el comportamiento de liberación; se considera terminado cuando las conexiones repetidas ya no muestran un uso de memoria que aumente de forma constante.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
C#
Estrellas
4.4k
Forks
993
Merge medio
9 d 21 h
PR fusionados (30 d)
1

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de sshnet/SSH.NET

Todos los issues de sshnet/SSH.NET

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.