FTP现有连接被远程主机强行关闭

问题描述:



我收到一条错误消息,提示现有的连接已被远程主机强行关闭."

我不确定FTP服务器是否已打开端口990.

我的代码如下

Hi,

I am getting an error as "An existing connection was forcibly closed by the remote host."

I am not sure FTP server has open the port 990.

my code as follows

FtpWebRequest request = null;
FtpWebResponse response = null;

request = (FtpWebRequest)WebRequest.Create(new Uri("ftp://ftp.example.com:990"));

request.UsePassive = true;
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(username, password);
request.Proxy = null;
request.EnableSsl = true;
request.UseBinary = false;
request.KeepAlive = false;

request.Timeout = int.MaxValue;
request.ReadWriteTimeout = int.MaxValue; //10000000;
response = (FtpWebResponse)request.GetResponse();


但是我能够通过使用端口990通过CoreFtp进行访问,并且在使用CoreFtp连接到FTP服务器时,如果我接受证书,那么会弹出一个包含服务器证书的窗口,然后我已连接到FTP服务器.
请帮助我几天来要解决的问题.

如何在我的C#程序中处理FTP服务器认证?
获取响应时出现错误,即request.GetResponse().
我不确定连接是否建立.

在此先感谢


But i am able to access through CoreFtp by using port 990 and while using CoreFtp to connect to FTP server it pops up a window which has Server certificate if i accept the certificate then i am connected to the FTP server.
Please help me what is the issue i am trying for this for couple of days.

How to handle the FTP server certification in my C# program?
I am getting error while getting response, i.e, request.GetResponse().
I am not sure the connection is established or not.

Thanks in advance

阅读本文:
解决FtbWebRequest中的证书问题 [ ^ ]
Read this article:
resolving problem with certificate in FtbWebRequest[^]