anonymous user It looks more like a SocketException. Can you confirm if the issue is observed intermittently and in the full exception trace you see System.Net.Sockets.SocketException trace?
If you are running your code in the function app consumption plan then this could observed when your application have utilized all the available sockets for the consumption plan. The suggestion would be reuse the connection object.
If you are executing in other plans and the issue is not intermittently then verify whether your function is under VNET that would cause this issue. The issue could also observed due to your FTP server end where the connection could be established from the function to your ftp server. If the issue is not intermittently then I will suggest to verify your FTP server whether there is any configuration/firewall that is blocking the connection.
Sharing some of the reference articles:
https://devblogs.microsoft.com/premier-developer/reducing-snat-port-consumption-in-azure-app-services/
https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-intermittent-outbound-connection-errors