ID: 44224 User updated by: jmichae3 at yahoo dot com Reported By: jmichae3 at yahoo dot com Status: Bogus Bug Type: FTP related Operating System: Windows XP Pro PHP Version: 5.2.5 New Comment:
Resource id #7 dest=pwdgen-perl.html src=./code/pwdgen-perl.html PHP Warning: ftp_put(): php_connect_nonb() failed: Bad file descriptor (9) in C:\www\jimm\ftp5.php on line 101 PHP Warning: ftp_put(): Entering Passive Mode (69,65,26,137,81,228) in C:\www\jimm\ftp5.php on line 101 --------!FTP upload has failed!---------- retry: success: dest=pwdgen-perl.html src=./code/pwdgen-perl.html my retry code is still needed, despite ftp_pasv. by the way, it doesn't do it on this file every time. random freak error, as usual. Previous Comments: ------------------------------------------------------------------------ [2008-02-24 00:58:33] [EMAIL PROTECTED] The manual is amazing thing, especially the friendly notes: "If you are having timeouts uploading a file, even very small files, you might have a look at ftp_pasv() And don't forget to do it after your ftp_login();" ------------------------------------------------------------------------ [2008-02-23 01:35:08] jmichae3 at yahoo dot com 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 this bug report at http://bugs.php.net/?id=44224&edit=1