|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-05 21:27 UTC] maxcamo at gmail dot com
Description:
------------
Hi,
with MSSQL 2005,Apache 2.2.11 and PHP 5.2.6 i get this error when i
try to connect to the db
Changed database context to
The error raise up when I try to connect to the DB.
connections timeout are high
mssql.connect_timeout = 300
mssql.timeout = 300
It happen randomly, but more frequently when the site traffic si very
high
Reproduce code:
---------------
$Maxtries=60;
$delayMin=50000;
$delayMax=100000;
$delay=rand($delayMin,$delayMax);
$log_filename="conn_failed.log";
$tries=1;
$connDb = @mssql_connect($host, $user, $pwd));
if ($connDb)
mssql_select_db($db, $connDb);
while(!$connDb){
if ($tries>=$Maxtries){
//echo "Database failed to respond.";
$fp = fopen($log_filename,"a+");
fputs($fp, gmdate("M d Y H:i:s") . ": Errore Connessione \r\n");
fclose($fp);
exit;
}
usleep($delay*$tries);
$connDb = @mssql_connect($host, $user, $pwd));
if ($connDb)
mssql_select_db($db, $connDb);
$tries++;
}
if ($tries>1){
$fp = fopen($log_filename,"a+");
fputs($fp, gmdate("M d Y H:i:s") . ":: Try:$tries :: ".$ServerName.":: ".mssql_get_last_message()." :: ". $pageName . "\r\n");
fclose($fp);
}
Expected result:
----------------
Db Connection
Actual result:
--------------
Mar 05 2009 21:08:19:: Try:2 :: B-C2N1:: Il contesto di database ?
stato sostituito con 'dbName'. :: /index.html
Mar 05 2009 21:08:20:: Try:8 :: B-C2N1:: Il contesto di database ?
stato sostituito con 'dbName'. :: /page2.html
Mar 05 2009 21:09:26:: Try:6 :: B-C2N1:: Il contesto di database ?
stato sostituito con 'dbName'. :: /page3.html
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 01:00:01 2025 UTC |
ok but i can't connect to the db, chaging the script like this if ($connDb) mssql_select_db($db, $connDb); else $lastmsg=mssql_get_last_message() and... fputs($fp, gmdate("M d Y H:i:s") . ":: Try:$tries :: ".$ServerName.":: ".$lastmsg." :: ". $pageName . "\r\n"); i dont' get any mssql errors, but i get the same problem I see this error randomly, or on heavy load, i thinkok but i can't connect to the db, chaging the script like this if ($connDb) mssql_select_db($db, $connDb); else $lastmsg=mssql_get_last_message() and... fputs($fp, gmdate("M d Y H:i:s") . ":: Try:$tries :: ".$ServerName.":: ".$lastmsg." :: ". $pageName . "\r\n"); i dont' get any mssql errors, but i get the same problem I see this error randomly, or on heavy load, i think