Skip to content

Handle leak when connection to SSH server fails #87

@zhanghfeng

Description

@zhanghfeng

I find handle leak occurred when use sshClient to connect a linux machine which power status is OFF.

occurred conditions & version

target linux machine is power off and version is 2016.0.0

handle information

I use the process explorer tool to analyze the issue. I find that \Device\Afd is continuous increase.

  • Type:File
  • Name:\Device\Afd

sample

using Renci.SshNet;
using Renci.SshNet.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace SSHNETTEST
{
    class Program
    {
        static void Main(string[] args)
        {
            string host = "192.168.154.201";//IP Address of connect target linux machine, and power off this machine
            string username = "root";//user name 
            string password = "abc123$%^";//password
            for (var i = 0; i < 1000000; i++)
            {
                SshClient sshClient = new SshClient(host, 22, username, password);
                try
                {
                    sshClient.Connect();
                    sshClient.Dispose();
                }
                catch
                {
                    sshClient.Dispose();
                }
                Thread.Sleep(3 * 1000);
            }
        }
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions