PHP Jquery Ajax Call Throws Net::Err_Empty_Response

Java with ajax - ERR_EMPTY_RESPONSE - Ajax response throws error while server is processing the request

It does sound like you are running up against some kind of a timeout. There are any number of places where a 4+ minute request can be timed out--browser, web servers, application servers...maybe even network devices and operating systems. Usually, the lowest timeout values are set by web servers.

Sounds like your running on tomcat, which I'm less familiar with, but you might be able to find some good information at https://tomcat.apache.org/connectors-doc/common_howto/timeouts.html. There's likely a way to configure things like asyncTimeout.

However, I would reiterate my prior comment (which I know you've taken heed of):

I would also second @DelightedD0D 's suggestion of using service workers or some other mechanism (such as polling). AJAX isn't really built for requests this long, so you'll likely run in to other issues.

Even the documentation I pointed to recommends against setting these to extreme values.

As I mention, it sounds like you ARE going a different route, from your comment:

@TheMadDeveloper DelightedD0D: From what you guys have suggested I am thinking to use websocket for this scenario. Do you think it's a good idea? although I am stuck stackoverflow.com/questions/37940540/

I think this is a wise decision, although websockets maybe be a little bit of an overkill. From what I gather, you don't really need the server and the client to be constantly talking while your task is being performed. Really, you just want to know when it's finished.

If you haven't gone too far down the websocket path, you might take a look at Server-Sent Events (SSE).

This post has some info that's specific to Tomcat. Also see this post for a detailed comparison of SSE and websockets.

Hope that helps!

Zend File Transfer Adapter Http is breaking my AJAX response, why?

It seems the syntax of your MimeType validator is wrong:

$adapter->addValidator('MimeType', false, ['extension' => 'text/plain']);

Should probably be:

$upload->addValidator('MimeType', false, array('text/plain'));

As described:

https://framework.zend.com/manual/1.12/en/zend.file.transfer.validators.html

Since your file won't pass the (impossible) validation test - I am guessing this is what then leads to no results?

getting this net::ERR_EMPTY_RESPONSE error in browser

Process Your Images Asynchronously

The Problem

I had the same thing happening to me. I found out that uploading large files were not the issue, it was the processing of the files after the upload by Paperclip that was the problem.

The browser has no problem keeping the connecting alive when it is actively uploading (or downloading) a file, but Paperclip was taking too long to process the files after they were uploaded, which the browser interprets as nothing happening. So if that processing takes too long (~1 min) the browser thinks something went wrong and returns an ERR_EMPTY_RESPONSE.

The Solution

I installed and implemented the wonderful delayed_paperclip gem, which pushes all the Paperclip processing to asynchronous tasks.

This means that once the files are uploaded, the request is completed and the browser gets an immediate response instead of waiting for Paperclip to process the files.

Problem solved.



Related Topics



Leave a reply



Submit