I'm using ajax to upload a group of ~50 files, all <= 5MB. If the connection is on the slower side, the upload will "timeout" without even finishing the first upload (approx ~45 seconds into upload).
In Firefox, ajax will fail with an 'error' response but no further info. In Chrome, I get an net::ERR_CONNECTION_RESET error.
I've checked my Apache and php.ini settings, and I believe they are all sufficient.
post_max_size = 1000M
upload_max_filesize = 15M
max_input_time = -1
max_execution_time = 0
max_file_uploads = 50
memory_limit = 128M
I've also tried setting ajax's timeout parameter to 0. My ajax request looks sort of like this:
return $.ajax({
url: ajaxpath,
type: 'post',
data: formData,
dataType: 'json',
timeout: 0,
xhr: function(){
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload) myXhr.upload.addEventListener('progress',function(e){
uploadProgress(e,item);
},false);
return myXhr;
},
processData: false,
contentType: false
}).fail(function(jqXHR,textStatus,errorThrown){
console.log(textStatus,errorThrown);
});
}
With quicker connections, I don't seem to get this problem. If I use my browser's developer tools to throttle the speed, it'll happen, which is what I'm doing to replicate my users' situation.
Am I missing a setting somewhere? How can I keep the upload alive?
Using the mod_reqtimeout Apache module ended up solving my problem:
RequestReadTimeout header = 20-40, MinRate = 500 body = 20, MinRate = 500
I found this suggestion at the bottom of a similar question.
For reference, I tried upping various ini settings, the Apache TimeOut directive, as well as the set_time_limit php function with no success.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With