C# Renci.SshNet.Sftp Connect throwing ArgumentNullException

主宰稳场 提交于 2019-12-06 15:21:52

It seems that the only imaginable scenario, when the PasswordAuthenticationMethod.Authenticate can pass an uninitialized wait handle to WaitHandle.WaitAny is when the session is closed while the authentication is ongoing.

If the session is closed due to a timeout, setting a higher timeout can resolve the problem, as you have found yourself.

A simpler code to set the timeout is:

var _sftpClient = new SftpClient(_hostName, _userName, _password);
_sftpClient.ConnectionInfo.Timeout = TimeSpan.FromSeconds(60);

You seem to be using an old version of SSH.NET (probably the version 2013.4.7 available in NuGet). As the relevant part of the code was refactored in later versions, upgrading might solve this problem too. You should do it anyway as the NuGet SSH.NET package is really old.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!