Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected Connection Reset: A PHP or an Apache issue?

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 was loading.

I have tested this on Firefox and IE, same thing happens. So, I am guessing this is an Apache/PHP config problem. Here are few things I have set.

PHP.ini

max_execution_time = 300000 
max_input_time = 300000
memory_limit = 256M 

Apache (httpd.conf)

Timeout 300000
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 0

Are the above correct? What can be causing this and what can I set?

I am running PHP (5.2.12.12) as a module on Apache (2.2) on a Windows Server 2003.

It is very likely this is an Apache or PHP issue as all browsers do the same thing. I think the script runs for exactly 10 mins (600 seconds).

like image 789
Abs Avatar asked Dec 26 '09 22:12

Abs


4 Answers

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.

like image 184
act28 Avatar answered Nov 16 '22 17:11

act28


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.

like image 2
gregn3 Avatar answered Nov 16 '22 19:11

gregn3


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.

like image 1
Tonio Avatar answered Nov 16 '22 18:11

Tonio


I had an issue where in certain cases PHP 5.4 + eAccelerator = connection reset. There was no error output in any log files, and it only happened on certain URLs, which made it difficult to diagnose. Turns out it only happened for certain PHP code / certain PHP files, and was due to some incompatibilities with specific PHP code and eAccelerator. Easiest solution was to disable eAccelerator for that specific site, by adding the following to .htaccess file

php_flag eaccelerator.enable 0

php_flag eaccelerator.optimizer 0

(or equivalent lines in php.ini):

eaccelerator.enable="0"

eaccelerator.optimizer="0"

like image 1
Gavin G Avatar answered Nov 16 '22 18:11

Gavin G