I have a PHP scripts that downloads and process some files. Sometimes the number of files is very large, so it takes some time.
But when there are a lot of files to process, the connection interrupts with a "ERR_CONNECTION_RESET" error (Chrome).
Here's my configuration:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 0
max_input_time = -1
memory_limit = 512M
I have a shared hostind. Anyone knows how to fix this?
I actually stumbled across this problem doing a very similair thing, my problem (in case it helps anyone) was that I was creating an Object every time I called my function, ie:
I simply changed it too:
Noob I know but hope this helps someone else.
On my IIS server with ASP.NET MVC, I accidentially generated the
ERR_CONNECTION_RESET
error in Google Chrome due to the fact that my HTTP status code description contained new line characters (\r\n
).I. e. this would generate the error:
To resolve it, I simply removed the newline characters.
Another issue may be that the status code description is too long.
ERR_CONNECTION_RESET
usually means that the connection to the server has died without any responses to the client – not even some kind of HTTP 5xx error. This means that the entire PHP process has died without being able to shut down properly.This is usually not caused by something like an exceeded memory_limit, because that's something PHP would handle gracefully. This must be some sort of Segmentation Fault or similar. If you have access to error logs, check them. Otherwise, you might get support from your hosting company.
Cleaning cookies resolved it when I had this issue on
Google chrome
If there are too many files to process, you'll eventually stumble upon this issue whatever your configuration. Even if you disable all timeouts server-side, the client itself has its own safety features and will eventually timeout after a certain time — something you can't control.
“You are doing it wrong” here. You cannot do any heavy computation in a HTTP request because of this kind of protocol limitations (TCP, HTTP).
Your request has to spawn some kind of background task that will notify of its progress from time to time. Using a shared hosting with PHP only, this might not be easy to accomplish, so you may want to find another way of doing your heavy computation.