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
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