The ftp client is able to see the file and connect to the server, but the handshake is failing. I am able to use the GUI client to access the same file with no issues. If I do not use the proxy in my code, the transfer fails on a timeout.

Using GUI sometimes I cannot connect or I can connect for a while(sometimes also list few directories) but then error message comes:
Proxy request failed, can't connect through proxy server
Transfer channel can't be opened. Reason: An established connection was aborted by the software in your host machine.
Could not retrieve directory listing
Entering Passive Mode (195,53,156,45,38,155)

I have done investigation also with network team and they say ports are open correctly and that the issue is not with network. As usual They say that it seems connection is ended from FTP server side. I cannot talk to anyone from FTP server side unfortunately...

I am wondering about two things:
1) port range for data connection is not correctly defined on network firewall or remote FTP
2) firewall or antivirus software on FTP server side cuts the outbound(maybe inbound) traffic.