skip to Main Content

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!

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. I believe there are callback functions available with this that you could use to call an API or capture failures and handle them appropriately. For example, you could display a message to the user, such as "Sorry, there was an error. Please try again," allowing them to re-attempt the upload. Additionally, you could use its resumable support so that it can pick up from the data already uploaded rather than starting from scratch, thereby hopefully mitigating the likelihood of the same error occurring when there is less data to upload.

    see: https://github.com/blueimp/jQuery-File-Upload/wiki/Options
    and see: https://github.com/blueimp/jQuery-File-Upload/wiki/Chunked-file-uploads

    $('#fileupload')
        .on('fileuploadadd', function (e, data) {/* ... */})
        .on('fileuploadsubmit', function (e, data) {/* ... */})
        .on('fileuploadsend', function (e, data) {/* ... */})
        .on('fileuploaddone', function (e, data) {/* ... */})
        .on('fileuploadfail', function (e, data) {/* ... */})
        .on('fileuploadalways', function (e, data) {/* ... */})
        .on('fileuploadprogress', function (e, data) {/* ... */})
        .on('fileuploadprogressall', function (e, data) {/* ... */})
        .on('fileuploadstart', function (e) {/* ... */})
        .on('fileuploadstop', function (e) {/* ... */})
        .on('fileuploadchange', function (e, data) {/* ... */})
        .on('fileuploadpaste', function (e, data) {/* ... */})
        .on('fileuploaddrop', function (e, data) {/* ... */})
        .on('fileuploaddragover', function (e) {/* ... */})
        .on('fileuploadchunkbeforesend', function (e, data) {/* ... */})
        .on('fileuploadchunksend', function (e, data) {/* ... */})
        .on('fileuploadchunkdone', function (e, data) {/* ... */})
        .on('fileuploadchunkfail', function (e, data) {/* ... */})
        .on('fileuploadchunkalways', function (e, data) {/* ... */});
    

    I hope this helps

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search