Bug #44300 [Com]: mssql_connect fails sometimes

2012-11-20 Thread alfa77 at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=44300&edit=1

 ID: 44300
 Comment by: alfa77 at gmail dot com
 Reported by:alfa77 at gmail dot com
 Summary:mssql_connect fails sometimes
 Status: Open
 Type:   Bug
 Package:MSSQL related
 Operating System:   Windows 2000
 PHP Version:5.2.5
 Block user comment: N
 Private report: N

 New Comment:

I think that this bug is not related to connection limit.
I have closed each connection at the end of the script (although it is not 
necessary due to documentation: 

mssql_close <...>
Note that this isn't usually necessary, as non-persistent open links are 
automatically closed at the end of the script's execution. 

Also, exec sp_who2 did not show a lot of connections (no more than 200).

I have solved this problem by using another extension (odbtp as a gateway on 
Windows server, PHP is hosted now on UNIX) - everything is all right now.


Previous Comments:

[2012-11-20 11:50:15] kishorekumar dot doreshetty at gmail dot com

Problem is due to connection limit. it would be good if you close connection 
once your done with sql part. use mssql_free_statement(resouceid) and 
connection close to db every page of you site.


[2010-07-17 18:59:07] opc dot three at gmail dot com

Related to Bug #35217.


[2010-02-25 10:18:16] healerx78 at yahoo dot com

trials


[2010-01-19 08:41:40] t dot zander at tuneup dot de

We're experiencing the same problem with Microsofts SQLSRV driver.
So it might be it's not just a driver problem.


[2009-12-03 17:37:29] dbuerer at leviton dot com

I too have suffered this same problem for the last couple of years on all of 
the 5.x release of PHP.  It works great for days then has problem for a few 
days then works great.  1-3 page reloads often solves the problem but not 
always. Unfortunatley support for this extension has been discontinued--I 
wonder if this is one of the reasons why?  I would like to try using Microsofts 
SQLSRV driver but converting an entire website from mssql to sqlsrv is going to 
be a lot of work!




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=44300


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=44300&edit=1


#44300 [Opn]: mssql_connect fails sometimes

2008-03-09 Thread alfa77 at gmail dot com
 ID:   44300
 User updated by:  alfa77 at gmail dot com
 Reported By:  alfa77 at gmail dot com
 Status:   Open
 Bug Type: MSSQL related
 Operating System: Windows 2000
 PHP Version:  5.2.5
 New Comment:

I think that this problem occurs due to usage of old DB-Lib for
connecting to MSSQL. There are another bug – that you can’t fetch
varchar more than 256-character length (you have to convert it to
TEXT).
It’s a pity, but the best way to work with MSSQL now is using ADO (no
connection/long varchar/Unicode problems).


Previous Comments:


[2008-03-08 07:38:07] alfa77 at gmail dot com

Well, I found two solutions.
1) I use ADO to connect to MSSQL. ADO is more slower (up to 2 times!),
than mssql_* functions, but there are no connection problems
2) I set connection timeout in code:
function getmt()
{
   list($usec, $sec)=explode(" ",microtime());
   return ((float)$usec+(float)$sec);
}
$time_st=getmt();
$db=new CSql;
while(!$db->connect_db($Host, $Name, $Login, $Passw))
   if(round(getmt()-$time_st, 0)>60) break;
if(!$db->dbc) die("Connection failed!"); 

It is too hard to use odbc_* functions, because there are a lot of bugs
with TEXT field type – I must put it on the last position in query and
use CONVERT(varbinary, other way I get ODBC errors.

I hope that mssql_* and odbc_* problems will be solved in future PHP
releases.

----

[2008-03-01 03:30:06] alfa77 at gmail dot com

Description:

Hello!
The number of my site users has recently increased and I have faced the
following bug: 
mssql_connect function sometimes fails to connect to MSSQL. It works
fine for few hours, 
then suddenly fails, and the work is resumed in a few minutes.

Here is the part of my DB class (CSql)
function connect_db($server, $user, $password)
{
$this->dbc=mssql_connect($server, $user, $password);
if(!$this->dbc) return false;
return true;
}

The warnings in Apache log are
[Thu Feb 21 20:50:58 2008] [error] [client 82.200.***.***] PHP Warning:
mssql_connect() 
[function.mssql-connect]: Unable
to connect to server: 
** in **.php on line 22

When I reload the page on site, connection sometimes succeeds,
sometimes – fails.
Web-server configuration: Windows 2000 Server (SP4) + Apache 2 + PHP
5.2.5. Peak usage 
of CPUs is no more than 70%, RAM usage – no more than 50%. There is a
program on this server 
that works with MSSQL through ADO, and it never has connection
problems. There are no 
connection problems from LAN too.
SQL Server 2000 (SP4) is working on dedicated server (Windows 2000
Server (SP4)) 
which is connected to the web server by gigabit LAN. I have tested the
network adapters, 
they work fine. CPUs usage is no more than 60%, RAM usage – no more
than 70%.

I have already:
1) replaced ntwdblib.dll in PHP directory with a new version. Also, I
have installed MDAC 2.81
2) moved SQL Server to a  new, fast server.
3) tried to use mssql_connect or  mssql_pconnect.
4) tried to use server name or server IP and port as the first
parameter for mssql_connect
5) tried to connect through TCP/IP or Named Pipes.
6) When I cycled connection attempts, it succeeded in connection almost
every time (usually 
from the second or third attempt)
$db=new CSql;
$db_failed=1;
while(!$db->connect_db(DBHost, DBLogin, DBPassw))
{ 
   if($db_failed>=5) break;
sleep(2);
$db_failed++;
}
if(!$db->dbc) die("DB connection failed!");
7) I checked the network connection by using sockets or ODBC when
mssql_connect had failed. It worked fine!
if(!fsockopen("192.168.0.3", 1433, $errno, $errstr, 10))
WrLog("C:\\sqlerr.txt","Err1 (($errstr ($errno)))");
if(!odbc_connect("sqlsrv",DBLogin, DBPassw))
WrLog("C:\\sqlerr.txt","Err2");
8) There are no connection limits in SQL Server or PHP.ini
[MSSQL]
mssql.max_persistent = -1
mssql.max_links = -1

I examined Apache logs few months ago, when MSSQL worked on the same
server with Apache. 
There were no messages about connection problems. 






-- 
Edit this bug report at http://bugs.php.net/?id=44300&edit=1



#44300 [Opn]: mssql_connect fails sometimes

2008-03-07 Thread alfa77 at gmail dot com
 ID:   44300
 User updated by:  alfa77 at gmail dot com
 Reported By:  alfa77 at gmail dot com
 Status:   Open
 Bug Type: MSSQL related
 Operating System: Windows 2000
 PHP Version:  5.2.5
 New Comment:

Well, I found two solutions.
1) I use ADO to connect to MSSQL. ADO is more slower (up to 2 times!),
than mssql_* functions, but there are no connection problems
2) I set connection timeout in code:
function getmt()
{
   list($usec, $sec)=explode(" ",microtime());
   return ((float)$usec+(float)$sec);
}
$time_st=getmt();
$db=new CSql;
while(!$db->connect_db($Host, $Name, $Login, $Passw))
   if(round(getmt()-$time_st, 0)>60) break;
if(!$db->dbc) die("Connection failed!"); 

It is too hard to use odbc_* functions, because there are a lot of bugs
with TEXT field type – I must put it on the last position in query and
use CONVERT(varbinary, other way I get ODBC errors.

I hope that mssql_* and odbc_* problems will be solved in future PHP
releases.


Previous Comments:
----

[2008-03-01 03:30:06] alfa77 at gmail dot com

Description:

Hello!
The number of my site users has recently increased and I have faced the
following bug: 
mssql_connect function sometimes fails to connect to MSSQL. It works
fine for few hours, 
then suddenly fails, and the work is resumed in a few minutes.

Here is the part of my DB class (CSql)
function connect_db($server, $user, $password)
{
$this->dbc=mssql_connect($server, $user, $password);
if(!$this->dbc) return false;
return true;
}

The warnings in Apache log are
[Thu Feb 21 20:50:58 2008] [error] [client 82.200.***.***] PHP Warning:
mssql_connect() 
[function.mssql-connect]: Unable
to connect to server: 
** in **.php on line 22

When I reload the page on site, connection sometimes succeeds,
sometimes – fails.
Web-server configuration: Windows 2000 Server (SP4) + Apache 2 + PHP
5.2.5. Peak usage 
of CPUs is no more than 70%, RAM usage – no more than 50%. There is a
program on this server 
that works with MSSQL through ADO, and it never has connection
problems. There are no 
connection problems from LAN too.
SQL Server 2000 (SP4) is working on dedicated server (Windows 2000
Server (SP4)) 
which is connected to the web server by gigabit LAN. I have tested the
network adapters, 
they work fine. CPUs usage is no more than 60%, RAM usage – no more
than 70%.

I have already:
1) replaced ntwdblib.dll in PHP directory with a new version. Also, I
have installed MDAC 2.81
2) moved SQL Server to a  new, fast server.
3) tried to use mssql_connect or  mssql_pconnect.
4) tried to use server name or server IP and port as the first
parameter for mssql_connect
5) tried to connect through TCP/IP or Named Pipes.
6) When I cycled connection attempts, it succeeded in connection almost
every time (usually 
from the second or third attempt)
$db=new CSql;
$db_failed=1;
while(!$db->connect_db(DBHost, DBLogin, DBPassw))
{ 
   if($db_failed>=5) break;
sleep(2);
$db_failed++;
}
if(!$db->dbc) die("DB connection failed!");
7) I checked the network connection by using sockets or ODBC when
mssql_connect had failed. It worked fine!
if(!fsockopen("192.168.0.3", 1433, $errno, $errstr, 10))
WrLog("C:\\sqlerr.txt","Err1 (($errstr ($errno)))");
if(!odbc_connect("sqlsrv",DBLogin, DBPassw))
WrLog("C:\\sqlerr.txt","Err2");
8) There are no connection limits in SQL Server or PHP.ini
[MSSQL]
mssql.max_persistent = -1
mssql.max_links = -1

I examined Apache logs few months ago, when MSSQL worked on the same
server with Apache. 
There were no messages about connection problems. 






-- 
Edit this bug report at http://bugs.php.net/?id=44300&edit=1



#44300 [NEW]: mssql_connect fails sometimes

2008-02-29 Thread alfa77 at gmail dot com
From: alfa77 at gmail dot com
Operating system: Windows 2000
PHP version:  5.2.5
PHP Bug Type: MSSQL related
Bug description:  mssql_connect fails sometimes

Description:

Hello!
The number of my site users has recently increased and I have faced the
following bug: 
mssql_connect function sometimes fails to connect to MSSQL. It works fine
for few hours, 
then suddenly fails, and the work is resumed in a few minutes.

Here is the part of my DB class (CSql)
function connect_db($server, $user, $password)
{
$this->dbc=mssql_connect($server, $user, $password);
if(!$this->dbc) return false;
return true;
}

The warnings in Apache log are
[Thu Feb 21 20:50:58 2008] [error] [client 82.200.***.***] PHP Warning:
mssql_connect() 
[function.mssql-connect]: Unable to
connect to server: 
** in **.php on line 22

When I reload the page on site, connection sometimes succeeds, sometimes –
fails.
Web-server configuration: Windows 2000 Server (SP4) + Apache 2 + PHP
5.2.5. Peak usage 
of CPUs is no more than 70%, RAM usage – no more than 50%. There is a
program on this server 
that works with MSSQL through ADO, and it never has connection problems.
There are no 
connection problems from LAN too.
SQL Server 2000 (SP4) is working on dedicated server (Windows 2000 Server
(SP4)) 
which is connected to the web server by gigabit LAN. I have tested the
network adapters, 
they work fine. CPUs usage is no more than 60%, RAM usage – no more than
70%.

I have already:
1) replaced ntwdblib.dll in PHP directory with a new version. Also, I have
installed MDAC 2.81
2) moved SQL Server to a  new, fast server.
3) tried to use mssql_connect or  mssql_pconnect.
4) tried to use server name or server IP and port as the first parameter
for mssql_connect
5) tried to connect through TCP/IP or Named Pipes.
6) When I cycled connection attempts, it succeeded in connection almost
every time (usually 
from the second or third attempt)
$db=new CSql;
$db_failed=1;
while(!$db->connect_db(DBHost, DBLogin, DBPassw))
{ 
   if($db_failed>=5) break;
sleep(2);
$db_failed++;
}
if(!$db->dbc) die("DB connection failed!");
7) I checked the network connection by using sockets or ODBC when
mssql_connect had failed. It worked fine!
if(!fsockopen("192.168.0.3", 1433, $errno, $errstr, 10))
WrLog("C:\\sqlerr.txt","Err1 (($errstr ($errno)))");
if(!odbc_connect("sqlsrv",DBLogin, DBPassw))
WrLog("C:\\sqlerr.txt","Err2");
8) There are no connection limits in SQL Server or PHP.ini
[MSSQL]
mssql.max_persistent = -1
mssql.max_links = -1

I examined Apache logs few months ago, when MSSQL worked on the same
server with Apache. 
There were no messages about connection problems. 


-- 
Edit bug report at http://bugs.php.net/?id=44300&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44300&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44300&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44300&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44300&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=44300&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=44300&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=44300&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=44300&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=44300&r=support
Expected behavior:http://bugs.php.net/fix.php?id=44300&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=44300&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=44300&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44300&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44300&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44300&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=44300&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=44300&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44300&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=44300&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=44300&r=mysqlcfg