My application connects to FTP clients that are connected to the server via VPN. So far all clients supported active PHP and the library I used went with active FTP by default, so there was no issue. Now however we have installed some new clients that don't properly work over active PHP, so I found out that from the server (via the FTP cli and FileZilla over RDP) can connect to and talk to all clients via a passive connection.
When trying to establish a passive connection in PHP however, all FTP commands (such as nlist
) just time out. I came across this blog post, which provides a patch for a specific passive FTP issue (which is now available in regular PHP versions), so I tried testing it like so:
$conn = ftp_connect($address);
$login = ftp_login($conn, 'username', 'password');
ftp_set_option($conn, USEPASVADDRESS, false);
ftp_pasv($conn, true);
$contents = ftp_nlist($conn, '.');
var_dump($contents);
ftp_close($conn);
ftp_pasv
returns true, so it is switching over to passive mode, but ftp_nlist
times out, which it doesn't for active mode and the compatible clients.
What is so different between PHPs FTP implementation and the FTP cli application?
ftp_nlist
? + Show "FTP cli" log file (do I understand correctly what you run "FTP cli" from the same machine/server, that you are running you PHP code at?) – Martin Prikryl/usr/bin/ftp
.ftp_nlist
doesn't throw an error, it simply times out and returnsfalse
. – Padarom$address
is192.168.12.10
? + How do you run the PHP code? From command-line? From the same environment asftp
? + Do you have an access to server-side log file? If not, can you do Wireshark capture (or similar)? – Martin Prikryl