Using ftp_ssl_connect in PHP to download files from FTP, only intermittently works

Come here to discuss FileZilla and FTP in general

Moderator: Project members

Post Reply
Message
Author
7table7
500 Command not understood
Posts: 2
Joined: 2018-05-18 09:24
First name: Liam

Using ftp_ssl_connect in PHP to download files from FTP, only intermittently works

#1 Post by 7table7 » 2018-05-18 10:16

Hello,

Not sure if I've put this in the right forum, sorry.

I'm trying to connect to FTP remotely using PHP to save images for use on a webpage, but it only works now and then.

Very similar code works every time in an FTP that doesn't require encryption, so I think the problem must be there somehow.

A lot of the time I'm getting a 150 "File status okay; about to open data connection" response, which is confusing because the download doesn't then happen. Or, if I press refresh a few times, there's no warning and the download goes through. Looping the PHP to ensure there are no errors isn't really an option, the page load time would be horrific as I'm looking to download a number of images.

I've seen this same 150 warning in Filezilla in the past:

Response: 150 File status okay; about to open data connection.
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
Status: Disconnected from server
Status: Resolving address of [HOST]
Status: Connecting to [IP ADDRESS]:[PORT]...
Status: Connection established, waiting for welcome message...
Status: Initializing TLS...
Status: Verifying certificate...
Error: Remote certificate not trusted.
Error: Critical error: Could not connect to server
Status: Disconnected from server
Status: Delaying connection for 2 seconds due to previously failed connection attempt...
Status: Resolving address of [HOST]
Status: Connecting to [IP ADDRESS]:[PORT]...
Status: Connection established, waiting for welcome message...
Status: Initializing TLS...
Status: Verifying certificate...
Status: TLS connection established.
Status: Logged in

I've since trusted the certificate, so don't see this in Filezilla anymore, but it still happens in PHP.

Be great if someone could show me what's going wrong.

Cheers

User avatar
botg
Site Admin
Posts: 35562
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Using ftp_ssl_connect in PHP to download files from FTP, only intermittently works

#2 Post by botg » 2018-05-18 13:07

Most likely a faulty firewall interfering with the connection.

7table7
500 Command not understood
Posts: 2
Joined: 2018-05-18 09:24
First name: Liam

Re: Using ftp_ssl_connect in PHP to download files from FTP, only intermittently works

#3 Post by 7table7 » 2018-05-21 07:50

Thanks a lot!

The FTP firewall? How would I go about fixing that?

User avatar
botg
Site Admin
Posts: 35562
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Using ftp_ssl_connect in PHP to download files from FTP, only intermittently works

#4 Post by botg » 2018-05-21 08:37

Best option is to remove all firewalls between the client and the server.

Post Reply