Question

Ran into a very bizarre issue and am looking for direction.

Context: uploading large files (up to 100MB) in WordPress. As part of the process there is also a long task running on the server-side (pushing file to DropBox via their API using chunking), so the response is inevitably delayed for larger files. This part can be simulated easily by executing PHP's sleep() function.

Issue: Fineuploader gets to 100%, shows the waitingForResponse message for about 15 seconds (server is still not done processing at this point), then proceeds to restart the upload from scratch. After the second try it claims to have received nothing from the server and lists the upload as failed. Console debug messages:

[FineUploader] xhr - server response received for 0
XMLHttpRequest { readyState=4, timeout=0, withCredentials=false, more...}
[FineUploader] responseText = 

Server logs show two requests and server echoes the success JSON twice; in the end there are two files on the server.

Question: What can I do to resolve this? Can I return something to FineUploader regularly to ensure there is no timeout?

Was it helpful?

Solution

Fine Uploader has no timeout mechanism in place. If you are seeing a timeout, either the browser itself is forcing a timeout, or there is some appliance between the browser and your server that is timing out.

I have run into this issue in the past when utilizing AWS (Amazon Web Services). Similar to your situation, I had to perform some processing server-side after the entire file had been received before returning the response. During this processing, of course, no TCP traffic was occurring. It turned out that the ELB (Elastic Load Balancer) had a TCP idle timeout of 1 minute. Processing for large files exceeded this value, causing the ELB to terminate the request.

You can only return a response to Fine Uploader when you are DONE with the request/upload. If you truly want to wait to return a "success" response to Fine Uploader until your server-side processing is complete, you will need to figure out what is terminating your request. Your options are likely to either increase the timeout period on the device that is terminating your request, or simply delegate the processing to a separate thread server-side and return the success response as soon as all of the file bytes have been received and are in order.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top