ERR_CONNECTION_RESET with PHP script

后端 未结 5 1975
悲哀的现实
悲哀的现实 2021-01-24 17:52

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 proc

相关标签:
5条回答
  • 2021-01-24 18:33

    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:

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

    To resolve it, I simply removed the newline characters.

    Another issue may be that the status code description is too long.

    0 讨论(0)
  • 2021-01-24 18:39

    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.

    0 讨论(0)
  • 2021-01-24 18:40

    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.

    0 讨论(0)
  • 2021-01-24 18:44

    Cleaning cookies resolved it when I had this issue on Google chrome

    0 讨论(0)
  • 2021-01-24 18:46

    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:

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

    I simply 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.

    0 讨论(0)
提交回复
热议问题