Unexpected Connection Reset: A PHP or an Apache issue?

后端 未结 8 565
时光说笑
时光说笑 2020-12-10 15:05

I have a PHP script that keeps stopping at the same place every time and my browser reports:

The connection to the server was reset while the page w

相关标签:
8条回答
  • 2020-12-10 15:45

    Differences between 2 PHP configs were indeed the root cause of the issue on my end. My app is based on the NuSOAP library.

    On config 1 with PHP 5.2, it was running fine as PHP's SOAP extension was off.

    On config 2 with PHP 5.3, it was giving "Connection Reset" errors as PHP's SOAP extension was on.

    Switching the extension off allowed to get my app running on PHP 5.3 without having to rewrite everything.

    0 讨论(0)
  • 2020-12-10 15:49

    I'd try setting all of the error reporting options

    -b on error batch abort
    -V severitylevel
    -m error_level

    and sending all the output to the client

    <?php
    echo "<div>starting sql batch</div>\n<pre>"; flush();
    passthru('sqlcmd -b -m -1 -V 11 -l 3 -E -S TYHSY-01 -d newtest201 -i "E:\PHP_N\M_Create_Log_SP.sql"');
    echo '</pre>done.'; flush();
    
    0 讨论(0)
  • 2020-12-10 15:51

    I thought I would add my own experience as well.

    I was getting the same error message, which in my case was caused by a PHP error in an exception.

    The culprit was a custom exception class that did some logging internally, and a fatal error occurred in that logging mechanism. This caused the exception to not be triggered as expected, and no meaningful message to be displayed either.

    0 讨论(0)
  • 2020-12-10 15:57

    My PHP was segfaulting without any additional information as to the cause of it as well. It turned out to be two classes calling each other's magic __call() method because both of them didn't have the method being called. PHP just loops until it's out of memory. But it didn't report the usual "Allowed memory size of * bytes exhausted" message, probably because the methods are "magic".

    0 讨论(0)
  • 2020-12-10 15:58

    I had a similar issue - turns out apache2 was segfaulting. Cause of the segfault was php5-xdebug for 5.3.2-1ubuntu4.14 on Ubuntu 10.04 LTS. Removing xdebug fixed the problem.

    0 讨论(0)
  • 2020-12-10 16:07

    I also had this problem today, it turned out to be a stray break; statement in the PHP code (outside of any switch or any loop), in a function with a try...catch...finally block.

    Looks like PHP crashes in this situation:

    <?php
    
    function a ()
    {
        break;
    
        try
        {
        }
        catch (Exception $e)
        {
        }
        finally
        {
        }
    }
    

    This was with PHP version 5.5.5.

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