Re: SV: SV: mssql tcp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It may and it may not.  I now remember what causes this problem.  When a
TCP connection is closed by the client application, the connection is not
completely terminated by the system. The connection is placed into the
TIME_WAIT state in case a packet needs to be resent because of a transport
error. The length (called socket linger time) of this state is system
dependent. However, the client app can set this time via the
SO_LINGER scoket option. Unfortunately, you cannot directly access the
underlying socket to do this with DB-Library.

This is not an uncommon problem, in fact, you will see the saem thing
occur if you run the script directly with the commond line PHP
interpreter. Whether or not this problem goes away with the FrreTDS
version depends on if it explicitly changes the socket's linger
timeout. In general you can just ignore this problem. IF it really is an
issue, and the FreeTDS version doesn't solve it, then you can try
ODBTP (http://odbtp.sourceforge.net). It prevents the occurance
of TIME_WAIT states, and the odbtp/mssql hybrid extension supports all the
mssql extension's functions.

-- bob

On Tue, 15 Nov 2005, Joakim Ling wrote:

> Hi
>
> Interesting, so if I swap mssql library to FreeTDS (never heard of this before) my socket problem will disappear without changing the code?
>
> Do I have to change from ISAPI (IIS6) to CGI?
>
> // jocke
>
>
> -----Ursprungligt meddelande-----
> Från: Frank M. Kromann [mailto:frank@xxxxxxxxxxxx]
> Skickat: den 15 november 2005 17:23
> Till: Joakim Ling
> Kopia: php windows; Robert Twitty
> Ämne: Re: SV:  mssql tcp
>
> Hi Jocke,
>
> Well I work with PHP and MSSQL and I know a bit about the broblems too.
> The library used to build the extension (msdblib) is not thread safe so if
> you are using the extension on a hight trafic server under Apache or ISAPI
> you might find odd problems. This has nothing to do with PHP. Using it
> under CGI or FastCGI will remove all these problems.
>
> Another solution would be to use the mssql extension with another library.
> FreeTDS is providing an exelent replacement for msdblib. Look at
> http://kromann.info/php.php. The download site on the right hand side
> include this extension. It's called php_dblib.dll and it's a drop-in
> replacement for php_mssql.dll. No recoding required.
>
> - Frank
>
>
> > It doesn't matter, the problem lies within php. To solve this problem
> you have to use a client that usage pooling like ODBC -> MSSQL. So my next
> step is to rewrite all mssql code to ODBC.
> >
> > This is not a problem if you run a small mssql server, buy if you have
> over 100 databases with a lot of activity windows starts to act really
> strange because of a bug in php. (read more in Zend forum)
> >
> > But who works with php and mssql? :-) (except me)
> >
> > //Jocke
> >
> > -----Ursprungligt meddelande-----
> > Från: Robert Twitty [mailto:rtwitty@xxxxxxxxxxxxxxxxx]
> > Skickat: den 15 november 2005 14:20
> > Till: Joakim Ling
> > Kopia: php windows
> > Ämne: Re:  mssql tcp
> >
> > Are you using mssql_pconnect() to connect to the database?
> >
> > -- bob
> >
> > On Mon, 14 Nov 2005, Joakim Ling wrote:
> >
> > > Hi
> > >
> > >
> > >
> > > When I connect to my MSSQL server (internal) with mssql_connect, make
> a
> > > few queries etc and then close the connection link. It creates a TCP
> > > connection each time (for every query). I'm running Win 2003 STD,
> IIS6,
> > > PHP5, MSSQL2000. The problem is that the connection doesn't close
> > > correctly so after a few minutes I will have a lot of TCP connections
> > > that looks like this:
> > >
> > >
> > >
> > > (With "netstat -ap tcp")
> > >
> > >   TCP    w1new:22953            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22954            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22955            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22956            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22957            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22958            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22959            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22960            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22961            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22962            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22963            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22964            w1new:ms-sql-s         TIME_WAIT
> > >
> > >   TCP    w1new:22965            w1new:ms-sql-s         TIME_WAIT
> > >
> > >
> > >
> > > After rebooting and running a few minutes the list is full and
> Windows
> > > begins to act really strange, not so strange when mssql has more then
> > > 10000 TIME_WAIT connections waiting to close, but how to close
> them????
> > > mssql_close(); has no effect to this problem.
> > >
> > >
> > >
> > > I changed the TCPTimeWaitDelay value to 30 in regedit to increase
> > > connections, but still a huge problem. Anyone experience this before
> or
> > > knows if converting to ODBC would work better?
> > >
> > >
> > >
> > >
> > >
> > > Best regards
> > >
> > > Joakim Ling
> > >
> > >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux