Nicolas Gonzalez
Nicolas Gonzalez

Reputation: 11

ERR_CONNECTION_RESET when uploading file via ajax

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!

Upvotes: 1

Views: 4215

Answers (2)

schellingerht
schellingerht

Reputation: 5806

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

Upvotes: 0

Mark
Mark

Reputation: 125

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

Upvotes: 1

Related Questions