我当前正在网络上运行FileZilla FTP服务器。我的问题是,在看似随机的计算机上,当用户导航到目录(他们能够执行)并尝试ls(即数据传输)时,其端挂起以等待响应,而服务器报告此425: Can't open data connection for transfer
以上。该结果因所使用的客户端计算机而异,其中某些客户端(本地或远程)可以继续运行,而其他客户端则可以停留在此处。我知道这是因为像CWD
ing这样的简单FTP命令在20/21端口上运行,而FTP数据传输在其他端口号上运行,这反过来又可能被链中某个位置的防火墙阻止。我的问题是,如何确定这些不同的端口(如果确实是这个问题),就我所知,它们可能大于1024?
我对该项目的最终目标是实现一个非常简单的FTP解决方案,理想情况下使用WinINet,但是到目前为止,我遇到了相同的问题:
BOOL CWebFileFinder::FindFile(const CString& URL)
{
CString ServerName;
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType = AFX_INET_SERVICE_FTP;
if (AfxParseURL(URL, dwServiceType, ServerName, strObject, nPort))
{
m_Connection = m_Session.GetFtpConnection(ServerName, m_Username, m_Password, nPort/*, true*/); // results in findfile still failing
if (m_Connection)
{
m_Connection->SetCurrentDirectory("sms"); // CDs into this dir
m_Finder = new CFtpFileFind(m_Connection);
if (m_Finder)
{
More = m_Finder->FindFile(_T("*.*")); // hangs here
}
}
}
catch (CException* pEx)
{
CString str;
LPTSTR error = str.GetBuffer(255);
pEx->GetErrorMessage(error, 255);
pEx->Delete();
str.ReleaseBuffer();
}
return More;
}
据我所知,我要么需要在LIST之前调用打开此数据端口,要么找到阻止这些端口的防火墙并创建防止该端口的规则(https://serverfault.com/a/278246)。当然,我也可能完全落伍了-任何见解都将得到[[greatly感激!
WinInet不支持加密的FTP。参见C++/Win32 The basics of FTP security and using SSL。