1

When I send an ajax request using jquery to upload a file I get "ERR_CONNECTION_RESET" after 120 seconds always. So, I decided to show in the console the progress of the uploading, and for my surprise every 30/40 seconds it came back to 0% - I mean, it showed 1% then 2% etc etc.. and then 0% again.

$.ajax({
    xhr: function() {
        myXhr = $.ajaxSettings.xhr();
        if(myXhr.upload){
            myXhr.upload.addEventListener("progress",function(e){
                console.log(Math.round((e.loaded / e.total * 1000) / 10) + '%');  }, false); } return myXhr; },
    async:      true,
    url:        '/?p=admin&sp=gen_edit&s&n',
    type:       'POST',
    data:       formdata,
    dataType:   'json',
    error:      function(xhr, textStatus, errorThrown){
        console.log('Error: ' + textStatus);
    },
    success:    function(data){
        location.reload();
    },
    cache: false,
    processData:false,
    contentType:false
});

Thanks!

2 Answers2

1

120 seconds (2 minutes) is a common inactivity timeout value for a lot of web servers, especially secure ones.

Mark
  • 116
  • 4
  • So funny.. im getting same error.. nothing to do with PHP.. but a good clue.. I used a stopwatch.. 30 seconds on the dot.. every time.. – Tim Davis Jun 13 '20 at 09:39
0

It sounds that you upload a large file:

  • check/set the post_max_size
  • check/set the upload_max_filesize
  • check/set the max_execution_time

All you can set in php.ini, .htaccess and ini_set() function. Examples can you find here: Increasing the maximum post size

Community
  • 1
  • 1
schellingerht
  • 5,726
  • 2
  • 28
  • 56