Я сделал настройку FTP-сервера (на основе ubuntu\vsftpd).
Я подключаюсь к этому ftp-серверу из Интернета, поэтому я активировал функцию безопасности SSL на сервере.
Дабы проверить, что все ок, сделал тест с FileZiLla -> работает. Журнал (из FileZilla):
Status: Connecting to ****:21...
Status: Connection established, waiting for welcome message...
Response: 220 (vsFTPd 3.0.2)
Command: AUTH TLS
Response: 234 Proceed with negotiation.
Status: Initializing TLS...
Status: Verifying certificate...
Command: USER ****
Status: TLS/SSL connection established.
Response: 331 Please specify the password.
Command: PASS ********
Response: 230 Login successful.
Command: SYST
Response: 215 UNIX Type: L8
Command: FEAT
Response: 211-Features:
Response: AUTH SSL
Response: AUTH TLS
Response: EPRT
Response: EPSV
Response: MDTM
Response: PASV
Response: PBSZ
Response: PROT
Response: REST STREAM
Response: SIZE
Response: TVFS
Response: UTF8
Response: 211 End
Command: OPTS UTF8 ON
Response: 200 Always in UTF8 mode.
Command: PBSZ 0
Response: 200 PBSZ set to 0.
Command: PROT P
Response: 200 PROT now Private.
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/home/****"
Command: TYPE I
Response: 200 Switching to Binary mode.
Command: PASV
Response: 227 Entering Passive Mode (*,*,*,*,*,*).
Command: LIST
Response: 150 Here comes the directory listing.
Response: 226 Directory send OK.
Status: Directory listing successful
Возвращаясь к моему коду C#... Я пытаюсь подключить свой сервер с помощью следующего кода, основанного на System.Net .FtpClient:
public PageDownloader()
{
this.Client = new FtpClient();
this.Client.Host = FTP_HOST;
this.Client.Port = 21;
this.Client.Credentials = new NetworkCredential(FTP_USER, FTP_PASS);
this.Client.DataConnectionType = FtpDataConnectionType.PASV;
this.Client.EncryptionMode = FtpEncryptionMode.Explicit;
this.Client.ValidateCertificate += Client_ValidateCertificate;
this.Client.Connect(); // Exception- System.TimeoutException: Timed out trying to connect!
}
void Client_ValidateCertificate(FtpClient control, FtpSslValidationEventArgs e)
{
// Never rich here
e.Accept = true; // Allow all - just for testing...
}
У меня есть это исключение:
System.TimeoutException: время ожидания попытки подключения истекло! в System.Net.FtpClient.FtpSocketStream.Connect (хост String, порт Int32, ipVersions FtpIpVersion) в System.Net.FtpClient.FtpClient.Connect()
Кто-то знает, почему это происходит? Почему я должен проверить?