Search code examples
jqueryfileuploadblueimp

jQuery File Uploader not able to handle 499 client closed error


An application uses the latest version of jQuery File Uploader and sometimes 499 errors (client closed request) are observed during uploads. My assumption is that this error appears if users are using unstable WLAN connections. Does anybody have experience with this issue and is there a fix for this? I'd like to extend the jQuery File Uploader in order to detect the 499 errors and re-upload the same image again until it goes through. Thanks!


Solution

  • Here is my solution, which works very well:

    In the add() config i added a retrial:

    add: function(e, data) {
     var attempts = 0;
     var maxAttempts = 2;
     var retryUpload = function () {
     if (attempts < maxAttempts) {
      attempts++;
      data.submit();
      }
     };
     ... your custom config ...
     data.submit().fail(function () {
      retryUpload();
     });
     ... 
    
    }
    

    With this solution, if the upload fails for any reasons, it just tries 2 times again to re-upload the same image.