我试图连接到sftp服务器,并且我没有得到任何异常或超时,只增加内存使用量。试图连接到sftp服务器时没有消息或超时
我使用的库EnterpriseDT.Net.Ftp
我的代码是这样的:
XmlConfigurator.Configure();
Module1.Logger = LogManager.GetLogger("SftpTester");
try
{
Module1.Logger.Info((object) "[EnterpriseDT] - Start");
Uri uri1 = new Uri("ftp://*****");
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
Uri& uri2 = @uri1;
int port = ****;
string str1 = "******";
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
string& UserName = @str1;
string str2 = "*******";
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
string& Password = @str2;
SecureFTPConnection secureFtpConnection = Module1.InitConnection(uri2, port, UserName, Password);
Module1.Logger.Info((object) "Connecting to ftp...");
secureFtpConnection.Connect();
Module1.Logger.Info((object) "Connection Successful!!!");
try
{
Module1.Logger.Info((object) "Disposing connection...");
secureFtpConnection.Dispose();
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
Module1.Logger.Info((object) "Connection Disposed.");
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
Exception exception = ex;
Module1.Logger.Error((object) ("Main() - " + exception.Message));
Module1.Logger.Error((object) ("StackTrace: " + exception.StackTrace));
if (exception.InnerException != null)
Module1.Logger.Error((object) ("InnerException: " + exception.InnerException.Message));
ProjectData.ClearProjectError();
}
finally
{
Module1.Logger.Info((object) "[EnterpriseDT] - End");
}
private static SecureFTPConnection InitConnection(ref Uri uri, int port, ref string UserName = "", ref string Password = "")
{
Module1.Logger.Info((object) "InitConnection() - Setting Up Connection");
SecureFTPConnection secureFtpConnection = new SecureFTPConnection();
secureFtpConnection.LicenseOwner = "*******";
secureFtpConnection.LicenseKey = "***********";
secureFtpConnection.ServerAddress = uri.Host;
Module1.Logger.Info((object) ("\tHost: " + uri.Host));
secureFtpConnection.UserName = UserName;
Module1.Logger.Info((object) ("\tUsername: " + UserName));
secureFtpConnection.Protocol = FileTransferProtocol.SFTP;
Module1.Logger.Info((object) ("\tProtocol: " + FileTransferProtocol.SFTP.ToString()));
secureFtpConnection.ServerValidation = SecureFTPServerValidationType.None;
Module1.Logger.Info((object) ("\tServerValidation: " + SecureFTPServerValidationType.None.ToString()));
secureFtpConnection.AuthenticationMethod = AuthenticationType.Password;
Module1.Logger.Info((object) ("\tAuthenticationMethod: " + AuthenticationType.Password.ToString()));
if (port > 0)
{
secureFtpConnection.ServerPort = port;
Module1.Logger.Info((object) ("\tServerPort: " + port.ToString()));
}
secureFtpConnection.Password = Password;
Module1.Logger.Info((object) ("\tPassword: " + Password));
return secureFtpConnection;
}
日志消息:
2014-09-27 04:50:22,783 [1] - [SftpTester] [EnterpriseDT] - Start
2014-09-27 04:50:22,799 [1] - [SftpTester] InitConnection() - Setting Up Connection
2014-09-27 04:50:22,971 [1] - [SftpTester] Host: *******
2014-09-27 04:50:22,971 [1] - [SftpTester] Username: *****
2014-09-27 04:50:22,971 [1] - [SftpTester] Protocol: SFTP
2014-09-27 04:50:22,971 [1] - [SftpTester] ServerValidation: None
2014-09-27 04:50:22,971 [1] - [SftpTester] AuthenticationMethod: Password
2014-09-27 04:50:22,971 [1] - [SftpTester] ServerPort: ****
2014-09-27 04:50:22,971 [1] - [SftpTester] Password: ******
2014-09-27 04:50:22,971 [1] - [SftpTester] Connecting to ftp...
任何想法,如果这是一个超时错误或如果我在黑名单中?
更新2014年7月10日
序列服务器:
- 密码验证
- 等待包
- 包到达
- 验证部分成功。尝试:密码,公钥,键盘交互
- 键盘交互认证
- 等待包
- 包到达
- 提示:密码:
- 等待包
- 包到达
- 验证部分成功。尝试:密码,公钥,键盘交互
- 等待包
- 包到达
- 提示:密码:
- 环路(9〜15)
更新
更新图书馆解决问题,是一个错误。
版8.6.1 (2014年9月23日)
固定KBI重入错误会导致认证尝试的一个循环。 修复了在将文件上传到不存在的目录时不引发异常的SFTP错误。 修复了OpenVMS SFTP服务器未被识别为SSH的SFTP问题。 修复只有一次重新连接的重试下载问题。 修复了一些使用FTPS的2012 R2机器上的“试图读取或写入受保护的内存”问题。
我想知道它是否是图书馆问题。您是否尝试过通过FileZilla等FTP客户端连接到同一台服务器?你有没有尝试过使用差异库?做这些工作的任何? – 2014-10-01 11:51:06
我无法使用ftp客户端进行测试,因为它是生产服务器,我没有直接访问它。 我需要检查这个当前库的问题,因为它是bussines的一个要求。 – 2014-10-01 12:23:24
EnterpriseDT.Net.Ftp是一个FTP客户端,所以我建议尝试使用另一个FTP客户端来排除上面使用的代码/库存在问题的可能性(这看起来不错)。如果另一个FTP客户端工作,那么上面的代码存在问题。如果另一个客户端无法工作,那么可能存在防火墙或FTP服务器配置问题。 – 2014-10-01 12:37:59