From: jmichae3 at yahoo dot com Operating system: Windows XP Pro PHP version: 5.2.5 PHP Bug Type: FTP related Bug description: ftp_put() Connection timed out
Description: ------------ expect ftp_put() and ftp_chdir() to work 100% of the time on a broadband cable connection. there are 421 web pages to upload, averaging 32k minimum/file. total upload time is about 3 minutes, so it shouldn't fail. Reproduce code: --------------- function upload($conn_id, $dest_file, $src_file) { global $remote_public_html_dir, $current_dir; if ($current_dir != $remote_public_html_dir . dirname($src_file)) { // change directory first if (ftp_chdir($conn_id, $remote_public_html_dir . dirname($src_file))) { $current_dir=$remote_public_html_dir . dirname($src_file); //only do this if chdir was successful. if (ftp_alloc($conn_id, filesize($src_file), $result)) { ftp_put($conn_id, basename($dest_file), $src_file, FTP_BINARY); } } } else { //directory hasn't changed. don't chdir. //since change directory was not needed, upload file ftp_put($conn_id, basename($dest_file), $src_file, FTP_BINARY); } } } //I don't have all the file parts to demonstrate. Expected result: ---------------- successful upload of entire web site in 3 minutes over cable internet connection with no errors. Actual result: -------------- have to try upload script to upload site up to 12 times sometimes with version 5.2.5 because there is always at least 1 error. Resource id #7 dest=index.html src=./lockdown/index.html PHP Warning: ftp_put(): Could not open data connection to port 3389: Connection timed out in C:\www\jimm\ftp5.php on line 101 --------!FTP upload has failed!---------- retry: success: dest=index.html src=./lockdown/index.html workaround: retry up to 50 times on failure. If you want that code, I can supply, but it is 74 lines long and is 2 functions. In version 5.2.3 it could not properly find an open port to use (sometimes fail 10 times in a row with different errors). it just increments. I *think* this got fixed in 5.2.5. However, I still get at least 1 timeout in 5.2.5. from the user's perspective, ftp_put() should just work. maybe it should try, say 20 or 100 times (?), and if it doesn't succeed, give up. then again this function should not be timing out in the first place. maybe there is a design flaw - I have no troubles uploading using filezilla ftp client. At least put a note in the documentation that you should retry on failure up to n times if you are not going to fix the code? -- Edit bug report at http://bugs.php.net/?id=44224&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44224&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44224&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44224&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44224&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44224&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44224&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44224&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44224&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44224&r=support Expected behavior: http://bugs.php.net/fix.php?id=44224&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44224&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44224&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44224&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44224&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44224&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44224&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44224&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44224&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44224&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44224&r=mysqlcfg