ERR_CONNECTION_RESET with PHP script

I have PHP scripts that download and process some files. Sometimes the number of files is very large, so it takes some time.

But when there are many files to process, the connection is aborted with the error "ERR_CONNECTION_RESET" (Chrome).

Here's my config:

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 0
max_input_time = -1
memory_limit = 512M

      

I have a common circulation. Does anyone know how to fix this?

+1


source to share


5 answers


If there are too many files to process, you will eventually run into this problem regardless of your configuration. Even if you disable all server-side timeouts, the client itself has its own security features and will eventually expire after a certain amount of time - something you have no control over.

"You're doing it wrong" here. You cannot do heavy computation in an HTTP request due to this kind of protocol limitation (TCP, HTTP).



There should be some kind of background task in your request that will notify you of its progress from time to time. Using shared hosting with only PHP can be tricky to accomplish, so you may want to find another way to accomplish your heavy calculations.

+2


source


ERR_CONNECTION_RESET

usually means that the connection to the server died without any response to the client - even some HTTP 5xx error. This means that the entire PHP process died without being able to shut down normally.



This is usually not caused by something like the memory_limit being exceeded, because something PHP will handle gracefully. It must be some kind of segmentation fault or something similar. If you have access to the error logs, check them. Otherwise, you can get support from your hosting company.

+8


source


I actually came across this problem, doing a very similar thing, my problem (in case it helps anyone) was that I was creating an object every time I called my function, that is:

function myFunction($param) {
    ...
    // Create an object
    $obj = new MyObject();
    ...
}

      

I changed it too:

function myFunction($param, $obj) {
    ...
    //Do stuff with $obj
    ...
}

// Create an object
$obj = new MyObject();
// Call Function
$myresult = myFunction($params, $obj);

      

Noob I know, but hope this helps someone else.

+1


source


Clearing the cookies resolved it when I had this problem on Google chrome

0


source


On my IIS server with ASP.NET MVC, I accidentally generated an error ERR_CONNECTION_RESET

in Google Chrome due to my HTTP status code description containing new string characters ( \r\n

).

I am. That is, this will result in an error:

public ActionResult Index()
{
    Response.StatusCode = 200;
    Response.StatusDescription = "This is a status code\r\nwith newline.";

    return View();
}

      

To solve this problem, I just removed the newlines.

Another problem might be that the description of the status code is too long .

0


source







All Articles