views:

851

answers:

2

Hello all,

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

A: 

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();
VolkerK
Thank you for the above, but I think I will leave the above for the last resort because those changes will take me some time to make! I have just confirmed this isn't a PHP problem as the last line of the PHP script is only a notice. The only think left is Apache??
Abs
And SQL server (but I don't think this can reset a connection, right?).
Abs
Is it really that hard to run this test script? Or at least to copy the existing script, replace exec() by passthru() and add two echo lines? It's only a test.
VolkerK
My use of exec is littered everywhere, this isn't an easy change. Plus, I have SQL Server Management Studio and this should be keeping a record of all errors that occur, so if there are errors I should see it there. Secondly, SQL Server is unlikely to cause the browser to report a connection reset. If anything did happen to SQL server, PHP would know and PHP would report this rather than the browser!! Right?
Abs
Btw, I am not refusing your help! :) I am trying it now!
Abs
Just tried this, but the above didn't even work for me. I get a straight, login denied for NT-Authority/System??
Abs
That's because you let the apache process run as "localsystem" (+ php as module/no impersonation). The new process spawned by passthru() inherits the account/security token. But that would also apply to exec(). Do you use the exact same command string except the -b/-m/-V option? Try it without the `-l 3`connection timeout option (though I doubt that the cause)
VolkerK
Yes, I use that same exact command. I will try it without "-l". Yes, PHP will run as an Apache process and this hasn't caused any problems when using the exec function.
Abs
The same thing happens :( - but why do you think its a SQL Server problem? What makes you think this, I would really like to now.
Abs
I don't think it's an SQLserver problem (I thought sqlcmd doesn't exit under certain conditions and passthru() will show you something like "press enter to continue") . Right now it seems to be an authentication problem. When a process runs as localsystem the integrated authentication uses the machine's credentials and not a specific user account (same as if you try to establish a smb network connection). The difference between exec() and passthru() at this point eludes me ;-) When you replace passthru() by exec() again in the test script your sql batch is executed?
VolkerK
No, I just get straight access denied error even after removing "-l". What if it returned "press enter to continue"? What does that mean? Does it mean SQLCMD doesn't exist and PHP is just waiting for nothing and therefore timesout??
Abs
yes, that was the general idea. sqlcmd waiting for some input, php waiting for sqlcmd to exit, timeout, the end. The failing authentication is a different story.
VolkerK
A: 

I have found out what the problem is. If anyone comes across this, I hope it helps.

There is a big difference in HP 5.2 and 5.3. If you are migrating up be careful and make sure your app is still functional on PHP first rather than jumping to other conclusions like I did.

For me, I had this in my windows event logger. Very helpful, right? It wasn't for me, it took me a whole day to find out the problem.

"faulting application Apache.exe, version 2.2.11, faulting module php5ts.dll, version 5.3.0, fault address 0x0000926a."

Abs
I am running into the same issue how did you fix it?
Isisagate