Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected server reset with php and apache

I have an application which interacts with a database. Suddenly and occasionally, pages are showing me Server connection Reset error in my Web browser. More surpisingly, accessing on a localhost page is triggering an alert on avast.

If I refresh pages using Ctrl+R, it happens occasionally. PHP is not showing any error messages, and it seems like the server is taking more time to respond than usual.

I am using wamp with apache 2.4, PHP 5.4.3. I am clueless as to where to start debugging or where to the problem is.

[Sun May 13 13:01:14 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun May 13 13:01:14 2012] [notice] Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/0.9.8x configured -- resuming normal operations
[Sun May 13 13:01:14 2012] [notice] Server built: May 13 2012 12:51:11
[Sun May 13 13:01:14 2012] [notice] Parent: Created child process 3660
Apache server interrupted...
arn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun May 13 13:01:15 2012] [notice] Child 3660: Child process is running
[Sun May 13 13:01:15 2012] [notice] Child 3660: Acquired the start mutex.
[Sun May 13 13:01:15 2012] [notice] Child 3660: Starting 64 worker threads.
[Sun May 13 13:01:15 2012] [notice] Child 3660: Starting thread to listen on port 80.
[Sun May 13 13:01:15 2012] [notice] Child 3660: Starting thread to listen on port 80.
[Sun May 13 13:01:28 2012] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Sun May 13 13:01:28 2012] [notice] Child 3660: Exit event signaled. Child process is ending.
[Sun May 13 13:01:29 2012] [notice] Child 3660: Released the start mutex
[Sun May 13 13:01:30 2012] [notice] Child 3660: All worker threads have exited.
[Sun May 13 13:01:30 2012] [notice] Child 3660: Child process is exiting
[Sun May 13 13:01:30 2012] [notice] Parent: Child process exited successfully.

UPDATE:

When 'connection request' occurs if is use cachegrind it shows partial list of callstack of methods. means it does not run all the code. it is showing some require_once calls and that it. next time if i retry to get the page, page executes and shows the whole callstack.

When 'connection request occurs' it shows

18 different functions called in milliseconds (1 runs, 18 shown)

after retrying

220 different functions called in 329 milliseconds (2 runs, 220 shown)

I dont know why it is showing 2 runs. also it is taking more time to execute page. before it was doing it less than 100 ms.

like image 753
varuog Avatar asked Apr 13 '13 13:04

varuog


1 Answers

  1. Restart you computer and close/disable all running applications including anti-virus keeping only a minimal set of running applications. Close everything even those applications that you are sure can't interfere - you never know..

  2. Make sure PHP shows all errors/warnings:

    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    

Make sure you review every warning you receive from PHP. It may give you a clue.

  1. Try to isolate a problem. Comment a chunk of code you suspect to cause the problem. Keep commenting until stop receive the error. Then start uncommenting until you find a problematic place. This way you can isolate a problematic code and once you see it, you may understand the problem.

  2. Add lots of statements that will write to log file (or just echo). Then you can analyze the log file and understand at which point error happens helping you to isolate the problem...

Eventually you will find the problematic code block and will be able to track the problem. Hopefully :)

like image 124
Dima L. Avatar answered Nov 10 '22 00:11

Dima L.