0
I have an application that connects to an ftp, but when trying to connect using proxy authentication I get an error.
O servidor remoto retornou um erro(514). Proxy retornou um erro.
This is the method that gives the error.
public string[] GetFileList()
{
StringBuilder result = new StringBuilder();
FtpWebRequest reqFTP;
try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + _ftpServerIP + "/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(_ftpUserID, _ftpPassword);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
if (usaProxy)
{
WebProxy proxy = new WebProxy("ip", "porta");
proxy.Credentials = new NetworkCredential("usuario", "senha");
reqFTP.Proxy = proxy;
}
WebResponse response = reqFTP.GetResponse(); // aqui ele vai pra excessao.
StreamReader reader = new StreamReader(response.GetResponseStream());
//MessageBox.Show(reader.ReadToEnd());
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
//MessageBox.Show(response.StatusDescription);
return result.ToString().Split('\n');
}
catch (WebException e)
{
throw new Exception(e.Message + "\n" + e.Status + "\n" + e.StackTrace);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
I think this error is authentication, user and password are correct? If they are then check if you have any other Webproxy options that should be set differently.
– Ricardo