0

I'm trying to download a FTP file from one of our clients, but in production it fails with this message: "Operation timeout exceeded", but if you try to open the FTP location from browser, it opens without problem. During develop this happened because of the proxy, but also blocked the browser. In production, the proxy was shutdown but still fails. I need help with this.

This is the code for the download

    using (WebClient vloftpClient = new WebClient())
    {
         vloftpClient.Credentials = new System.Net.NetworkCredential(vlcUsuario, vlcClave);
         vloftpClient.DownloadFile(@vlcUbicacionOrigen + @"/" + vlcNombreArchivoOrigen, pvcUbicacionDestino + @"/" + pvcProveedor + "_" + vlcNombreArchivoDestino);        
    }
  • 2
    "but if you try to open the FTP location from browser" what if you use an FTP client? You might be blocking port 21 (FTP) but not 80 and 443 (HTTP/S) – Dave S May 31 '17 at 17:36
  • "FTP location from browser" => Are you using `ftp://` URL in browser? Are you running the browser in the same production environment as your code? - Try using a standalone FTP client (like WinSCP) in the production environment instead of the browser and post its log file + Show us `WebClient` log file too: https://stackoverflow.com/q/9664650/850848 – Martin Prikryl Jun 01 '17 at 05:31
  • Is in the same enviroment has the system, – FaustusLoveless Jun 01 '17 at 20:12

1 Answers1

0

WebRequestClient offers a better solution for working such as mode of transfer. so use as below

FtpWebRequest objFtp;
objFtp.Method = ...DownloadFile
objFtp.ReadWriteTimeout = objFtp.Timeout = 'a value in terms of millisecond'

at last , try to download the files