Unexpected server reset with php and apache - php

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.

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..
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.
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.
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 :)

to restart Apache via PHP use the follow code in PHP
exec('/etc/init.d/httpd graceful');
and also look in the manual... and change the path to your httpd

Change apache listen port from 80 to 8080
file httpd.conf , change listen 80 to listen 8080 and restart apache

Re-try disabling temporarly the antivirus

Maybe it is not a right solution, but why not just try other WAMP version or maybe setup your system clock correct?. And have you tried to run Apache in minimal configuration? You may disable all extensions and modules (inc php itself) and if web server will work as expected you may turn one by one you modules. I don't know about your environment but you may also try to change working threads number and other values to minimal. I bet it doesn't help but at least you'll try.

If you have mod_security enabled try disabling and see if the same happens.. sometimes you can have over vigilant mod_security that will just go to http fail (sometimes can be as simple as inserting data with an ampersand into the database) and won't write any error to the server logs making it hard to troubleshoot, sounds similar to what you're experiencing, I would disable mod_security re-start server and see if the behavior has stopped!

It looks like some other people have encountered the same issue using Wamp:
Have you gone through each of the points enumerated in this post belonging to the official forum:
http://forum.wampserver.com/read.php?2,67660

Are you sure you don't have an include/require loop ?
That kind of loop make PHP eat up too much memory and apache kill itself to avoid it.
Or maybe some kind of 404 loop error ...
That kind of loop can happen if you have 404 errors sometimes. Here is an example :
You have a layout with an image which is missing, so it triggers a 404 errors. To display the page, the 404 errors add the layout around the error page which contains the missing image, which triggers another 404 errors.
Hope that helps.

Related

Apache error log: zend_mm_heap corrupted, child process exited with status 1 -- Restarting

I have seen some topics about 'zend_mm_heap' corrupted and 'child process exited with status nnnnn' but none of this topics lead to a solution. What does status 1 means in clear text, it is not clear what exactly happen.
Symptoms
This problem does not occur when the site is running without being logged in. Only when I logged in the problem sometimes happen when refreshing the page. Strange is that sometimes the html fails to load and sometimes resources like a CSS file or JS file. I also have seen that some resources take 6 seconds to 10 seconds to load. I think this is caused by restarting the server because of this error.
When above symptoms occur, the following (similar) info is written to the error.log file:
Error in error.log file:
zend_mm_heap corrupted
[Sun Feb 09 03:56:57 2014] [notice] AH00428: Parent: child process exited with status 1 -- Restarting.
[Sun Feb 09 03:56:57 2014] [notice] AH00455: Apache/2.4.3 (Win64) configured -- resuming normal operations
[Sun Feb 09 03:56:57 2014] [notice] AH00456: Server built: Aug 18 2012 14:13:48
[Sun Feb 09 03:56:57 2014] [notice] AH00418: Parent: Created child process 3460
[Sun Feb 09 03:56:57 2014] [notice] AH00354: Child: Starting 64 worker threads.
Configuration:
Intel I7 (Quadcore) chipset, 16GB RAM
Running latest XAMMP (or Z-WAMP, in both the same problem - see for Z-WAMP also http://zwamp.sourceforge.net/) on Windows 7 64 bit
Running APC -
For example:
Normal feedback (when problem does not occur):
What I want to know
Does have somebody info about Apache status 1 exit?
Am I able to debug this, how can I debug this?
There is a problem with APC (I use version 1.3.1) that cause this error, corrupt memory for some reason. I believe it has something do with session data because the problems only occur when logged in. My PHP class uses only a session when it is required to be logged in to be able to view the page. I have also checked my code but there is nothing abnormal or incomplete.
When I turn off the Windows extension php_apc.dll in the php.ini file everthing is working fine. No memory corruption and no delays. Also tried other cache extensions like xCache, eAccelerator, memcache and loads normally.
So I qualify this as a bug.

Long respond time because of Mod_SPDY or Session , Apache2 server

I'm work on an apache2 server (nginx) and for some reason the respond times have been very long. It can take up to 30Sec to get a respond from the server.
I have check the PHP code and also added a timer to it so it can’t be the code. I have also created a very simple dummy file but the delay is still there.
I have also restarted all services but the problem is still there.
I keep seeing the following Errors in the error-log and suspecting that it might be related to a session problem:
[Sun Oct 06 16:50:03 2013] [error] [client 69.201.188.61] [mod_spdy/0.9.4.1-397] [32734:32734:ERROR:spdy_session.cc(304)] Session error: INVALID_CONTROL_FRAME
[Sun Oct 06 15:32:13 2013] [error] [client 84.168.213.116] [mod_spdy/0.9.4.1-397] [18811:18811:ERROR:apache_spdy_session_io.cc(88)] ap_get_brigade failed with status 104: Connection reset by peer
I Googled these error logs but couldn’t really find anything.
Any suggestions?
Thank you for your help

What happens to a running PHP script with MySQL queries during a server restart?

I'm running a PHP script that converts a few hundred thousand records from a remote MySQL server to the local one. A few times during the transfer, the error_logs shows ...
[Wed Jul 03 17:02:36 2013] [notice] Graceful restart requested, doing restart
[Wed Jul 03 17:02:37 2013] [notice] SSL FIPS mode disabled
[Wed Jul 03 17:02:37 2013] [notice] Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_bwlimited/1.4 PHP/5.3.16 configured -- resuming normal operations
It's rare, and I can't find a reason for it, but the script seems to continue as though nothing happened. Testing if data was lost would be very cumbersome. So I'm wondering, what happens if a MySQL query is interrupted? And why does PHP seems to ignore the restart entirely, and just continue running as though nothing happened? Any thoughts on how/what to test?
That's an Apache log, not a PHP log. Your script is probably running in CLI (command line) so an Apache restart won't affect it. Otherwise it may have been restarted with -k graceful which will allow child processes to complete.
So I'm wondering, what happens if a MySQL query is interrupted
If MySQL is restarted, the script will fail (unless the programmer incorporated some extra robust error handling to deal with that situation).

Parent: Received shutdown signal -- Shutting down the server

Using wampserver and receiving this error:
Parent: Received shutdown signal -- Shutting down the server.
Google doesn't seem to have any solutions that work. Any ideas?
[Mon Jul 25 19:07:02 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Child process is running
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Acquired the start mutex.
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Starting 64 worker threads.
[Mon Jul 25 19:07:02 2011] [notice] Child 5828: Starting thread to listen on port 80.
[Mon Jul 25 19:07:40 2011] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Mon Jul 25 19:07:40 2011] [notice] Child 5828: Exit event signaled. Child process is ending.
[Mon Jul 25 19:07:41 2011] [notice] Child 5828: Released the start mutex
[Mon Jul 25 19:08:05 2011] [notice] Child 5828: All worker threads have exited.
[Mon Jul 25 19:08:05 2011] [notice] Child 5828: Child process is exiting
[Mon Jul 25 19:08:05 2011] [notice] Parent: Child process exited successfully.
Look at the Apache error log.
This error almost always occurs when another user shuts down a multi-user server. The Apache error log will tell you what happened so we can help if there are further issues.
Edit
Try this- go to C:\WINDOWS\System32\drivers\etc and make sure you have the following in it:
127.0.0.1 localhost
Restart WAMP, and see if anything has changed.
I got the same error. So, I quit the skype and run the wamp as administrator it works. After that I changed the skype listen port to 88. Now the wamp works fine.
Its the port conflict. So, either you may change the localhost port to 88 in httpd.config file.
This can also be caused by own stupidity, like in my case:
I've had a script on my server (Windows 2008 R2) that was configured to run every 5 minutes. It contained the following two lines:
net stop Apache2.4
net start Apache2.4
Strange enough this script was present for years and did never cause any remarkable effect for my websites. Only recently, Uptime Robot detected some downtimes.
To be honest, I don't know anymore why I had this script configured at all.
Solution:
To solve this, I simply deactivated the script in the Windows Task Scheduler.
Have you been messing with your httpd.conf file? I was messing with mine, and changed the first "listen" bit to Listen 8080 and got rid of a the 303 error and am able to start apache. Now I have a 404 error...which is an improvement I guess.
I have both iis and wamp installed on my windows machine, and accidentally I have opened iis for port 80, which caused the error you have experienced.
Either change the port that Wamp listens to, either the port the IIS listens to

mysql_connect() causes page to not display (WAMP)

I currently have a website running MySQL and PHP in which this is all working. I've tried installing WAMPServer to be able to work on the site on my own computer, but I have been having issues trying to get the site to work correctly.
HTML and PHP files work correctly (by going to http://localhost/index.php, etc.). But some of the pages display "This Webpage is not available" (in Chrome) or "Internet Explorer cannot display this webpage", which leads me to think there is an error is the server, as when the page doesn't exist, it typically dispays "Oops! This link appears to be broken" or IE's standard 404 page.
Each page in my site has an include() call to set up an instance of a class to handle all database transactions. This class opens the connection to the database in its constructor. I have found commenting out the contents of the constructor will allow the page to load, although this understandably causes errors later in the page.
This is the contents of the included file:
class dbAccess {
private $db;
function __construct() {
$this->db = mysql_connect("localhost","root","") or die ("Connection for database not found.");
mysql_select_db("dbName", $this->db) or die ("Database not selected");
}
...
}
As a note for what's happening here. I'm attempting to use the database on my site, rather than the local machine. The actual values of dbName, user, and password work when I plug them into my database software (Navicat Lite) and work correctly on the finalized version of the site, so I don't think the issue is with those values themselves, but rather some setting with Apache or Wamp.
This is an excerpt of my Apache error log for one attempt at logging into the site:
[Wed Apr 14 15:32:54 2010] [notice] Parent: child process exited with status 255 -- Restarting.
[Wed Apr 14 15:32:54 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Apr 14 15:32:54 2010] [notice] Server built: Dec 10 2008 00:10:06
[Wed Apr 14 15:32:54 2010] [notice] Parent: Created child process 1756
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Child process is running
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Acquired the start mutex.
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Starting 64 worker threads.
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Starting thread to listen on port 80.
I've tried searching for solutions online, but haven't been able to find anything to help. If you need any further information to help solve this issue, feel free to ask for it.
(One more note, I don't even have Skype on this computer, so I can't see it being an issue, as this conflict seems to be the default response for any Wamp issue.)
[Edit: Removed entry from the error log as it was solved as an unrelated issue]
[Edit: Looking through my hosts documentation, I found that all ports besides 80 and 443 (for HTTP and HTTPS) are blocked, meaning they don't allow external connections like what I was trying to do here. I've changed it to the local database, but I'm still receiving the same error. The issue is still open.]
I too encoutered this problem. The solution for me was to move the mysql_connect method out from its class and just call it directly.
Let's by-pass the apache for a moment. In the directory <wamp>/bin/php/php5.3.0 there is a php.exe that implements the cli sapi (the command line version).
Put the file test.php in that directory with
<?php
if ( !extension_loaded('mysql') ) {
die('the mysql extension is not present');
}
echo 'phpversion=', phpversion(), "\n"; flush();
echo 'client_info=', mysql_get_client_info(), "\n"; flush();
$mysql = mysql_connect('localhost', 'root', '') or die(mysql_error());
echo "seems to be working\n"; flush();
echo 'server_info=', mysql_get_server_info($mysql), "\n"; flush();
as the content. Then open a command shell, "go" to the directory
c:
cd c:\wamp\bin\php\php5.3.0
and run
php.exe -f test.php
It should print something like
phpversion=5.3.2
client_info=mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $
seems to be working
server_info=5.1.37
(though the versions will be different in your case)

Categories