Question

I am having problems uploading large files to a PHP script on a server. Everything works fine, except when larger files are uploaded. When uploading a file of size ~ 170MB (takes about 40 - 50 minutes) it has worked once, but failed all other times. A file of ~ 420MB (takes about 80 - 110 minutes) has not uploaded successfully. The weird thing is I get no error in the PHP log or Apache log, the session is just empty when the file is received and processed. I have all the reccomended settings

in PHP app:
ini_set('max_execution_time', '8640');// 24h 
ini_set("session.cookie_lifetime", '0'); // 24h
ini_set("session.gc_maxlifetime", '8640'); // 24h
ini_set("default_socket_timeout", '8640'); // 24h
ini_set("error_reporting", "true");
error_reporting(E_ALL|E_STRCT);

in .htaccess
php_value memory_limit 4194304000
php_value post_max_size 3145728000
php_value upload_max_filesize 3145728000
php_value max_input_time 8640

I am running a single EC2 micro instance behind an ELB on AWS. On the instance I run Ubuntu with Apache 2.4.6, PHP 5.5.3. Files are uploaded via the blueimp jQuery-File-Upload plugin (http://blueimp.github.io/jQuery-File-Upload/). The plugin claims that uploads up to 4GB should be possible. The plugin performs the upload via AJAX, don't know if it is related to the problem.

I get this error even if I do not access the instance via ELB, in other words accessing the application via the IP of the EC2 instance.

When performing the same actions on a localhost WAMP server I do not get any issue with large files.

I have printed out the client IP (this is the client value printed per entry in the PHP error log) before the ajax request is started and then again after it is completed and found that the port differs,

Before upload start
[client 105.224.7.32:53623]

After upload complete
[client 105.224.7.32:53633]

I do not know if the error is related to the upload time, the upload size, memory limitations, AWS, or maybe even something completely unrelated as I am not receiving any error messages.

Could this be related to the error? Any help or direction would be appreciated.

Was it helpful?

Solution

It seems this had been related to the browser's session timing out. I added functionality to ping the server every 60 seconds from the browser that is doing the file upload, and it fixed the error. I guess the port that differs (after the session seemed to be lost on the server) is due to a fresh connection request being sent from the browser after its session expired. I think this then resulted in PHP creating a new session for the request

OTHER TIPS

I have had a similar problem but this was due to a timeout because of SSL: The solution was to add an "SSLRenegBufferSize" line (with enough size) to the .conf file in the DIRECTORY-segment of the site, assuming Apache2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top