FTP File download error

Hello everyone,

I’m encountering a problem when attempting to download a file from an FTP server. This connection is established using a username and password. I’ve set up the “FTP scope activity” and implemented a “Download files” activity within it.

However, I’m facing an error message that reads: “RemoteException wrapping System.AggregateException: One or more errors occurred. —> RemoteException wrapping FluentFTP.FtpException: There was an error in downloading the file from the server. For more details, refer to the InnerException. —> RemoteException wrapping System.Net.Sockets.SocketException: The connection attempt failed because the remote party did not respond appropriately within the allotted time frame, or an established connection failed because the host failed to respond.”

I am using Studio 2021.10.10 with an enterprise license.
The FTP package is 2.3.0
The robot itself runs on a VM which has acces to all the required ports. I tried downloading the same file using winSCP and I encountered no issues.

Please advise. Thanks :slight_smile:

Edit1: I installed an earlier version the FTP Activities package and now I get this error:

Edit2: went back to FTP version 2.3.0 and tried something else:


The connection to the FTP server is ok, it can also see that a given filepath (file) exists, but it can’t download it.

Edit3: I created a script and used an Invoke Code activity. It works! But i’d rather use the UiPath activities.

click here for the code

Dim ftpAddress As String = “ftpAddress”
Dim ftpPort As Integer = portNumber
Dim filePath As String = “filePath”
Dim username As String = “username”
Dim password As String = “password”
Dim savePath As String = “destinationFilePath”

Dim ftpRequest As System.Net.FtpWebRequest = CType(System.Net.WebRequest.Create($“{ftpAddress}:{ftpPort}{filePath}”), System.Net.FtpWebRequest)
ftpRequest.Credentials = New System.Net.NetworkCredential(username, password)
ftpRequest.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
ftpRequest.UseBinary = True
ftpRequest.KeepAlive = False
ftpRequest.UsePassive = True

Try
Using response As System.Net.FtpWebResponse = CType(ftpRequest.GetResponse(), System.Net.FtpWebResponse)
Using responseStream As IO.Stream = response.GetResponseStream()
Using fileStream As IO.Stream = IO.File.Create(savePath)
responseStream.CopyTo(fileStream)
End Using
End Using
End Using
Console.WriteLine(“Download complete.”)
Catch ex As Exception
Throw New Exception("Error downloading file: " & ex.Message)
End Try

First of all I would recommend to verify the connection and permission using some FTP client - WinSCP, FileZilla or simillar.

One thing to check: The propperty “Local path” should be directory name, not file name - at least I use it this way in my automation.

Cheers

Hi @J0ska
I can access the FTP with no issue using winSCP. Please check my latest post update, as I created a script which connects to the FTP and downloads any file. Works like a charm.
I also tried using only the directory name in the “local path” field - I get the same error.

There is something buggy with this activities package and I can’t figure what & how.

I made a test with my FTP server and it works okay.
I connect to MS FTP.
I use the same version 2.3.0 of FTP Activities Pack.

Given “FTP Activities” is anyway just a wrapper for “FluentFTP” library you may want to code it using vb/c# and InvokeCode.

Or you may try to link some later version of “FluentFTP” library to your project, replacing the one used by “FTP Activities”…???

image

Cheers

You may also check this:

Cheers