I have the following code. Sometimes it runs without a problem, and other times it doesn't. Nothing changes in the code between the times it runs and fails. When it fails, the ftp_nlist count comes back with a file count of one. I know there are more than that in the directory. when we first discovered the problem, it would fail once every couple of weeks. Now it is failing on a daily basis.
Does anyone know what is going wrong or what I could look at to get this issue fixed?
$conn = ftp_connect(RECORDINGS_FTP_HOST);
if(!$conn) {
write_log_line("ABORTED: Could not connect to server:" . RECORDINGS_FTP_HOST . "\r\n", LOG_FILE);
exit;
}
if(!ftp_login($conn,RECORDINGS_FTP_USER,RECORDINGS_FTP_PASSWD)) {
write_log_line("ABORTED: Could not log in to server:" . RECORDINGS_FTP_HOST . "\r\n", LOG_FILE);
ftp_quit($conn);
exit;
}
ftp_pasv($conn, true);
// Download file list
$files = ftp_nlist($conn,"-t " . ARCHIVED_RECORDINGS); // -t means bring in the oldest first. So it will get processed first.
write_log_line("Files found " . count($files) ."\r\n", LOG_FILE);