From:             [EMAIL PROTECTED]
Operating system: Linux Red Hat 7.0
PHP version:      4.2.0
PHP Bug Type:     Sockets related
Bug description:  TIME_WAIT status

this is my setup:
php 4.2.0 with the socket extension, as a dynamically loaded module in
apache 1.3.23. it is running on is a red hat 7.0 box with kernel 2.2.19.

this is was i am trying to do: 
i am using the socket functions to connect to a server which is running a
ticketing software using a specifically designed protocol; the details do
not matter here. i'll call my webserver "webserv.com", the client calling
the script "client.com" and the ticketsystem "tixserv.com".

i think i am doing everything by the book - just a simple one-shot
tcp-client; writing some request to tixserv.com, reading the response and
closing the connection. i am using socket_create(), socket_connect(),
socket_write(), socket_read(), and finally socket_close(), pretty much the
same way as the example 2 ("Simple TCP/IP client") in the php manual. this
seems to work well (no errors or warnings).

this is my problem:
if i monitor the connection attempts with netstat, i am seeing the
following behaviour:

firstly, connections are established: from webserv.com to client.com and
from webserv.com to tixserv.com:

tcp    webserv.com:1558     tixserv.com:45007    SYN_SENT    1126/httpd   
      
tcp    webserv.com:www      client.com:1894      ESTABLISHED 1126/httpd   
      

then, the connection from webserv.com to tixserv.com is closed (using
socket_close() in the script), so the connection status goes to
TIME_WAIT:

tcp    webserv.com:1558     tixserv.com:45007    TIME_WAIT   -            
      
tcp    webserv.com:www      client.com:1894      ESTABLISHED 1126/httpd   
      

i see that to go to TIME_WAIT status is the correct way to behave for a
socket. but the problem is that httpd somehow seems to wait for the
TIME_WAIT status to go away and keeps the connection open during this time
(ESTABLISHED). this takes a really long time (at least 30 seconds or
more). at some time, the TIME_WAIT of the connection to tixserv.com
finally goes away, and the connection to the client falls into that
state:

tcp    webserv.com:www      client.com:1894      TIME_WAIT   -            
      

strange - my browser and php seem to ignore this: the script execution,
measured with microtime(), is around 800 miliseconds, of which at least
90% is response time by tixserv.com which is fine. also, my browser does
not need more than a second to display the script results. nonetheless,
the httpd connection on the server stays ESTABLISHED for at least 30
seconds.

the scary thing about this is that it gets worse if i start to stress the
server. i used jakarta-jmeter to simulate simultaneous requests. jmeter
did not behave the same as my browser: it actually waited until the httpd
connection status was really closed. this totally stressed webserv.com: i
had response times around 600 seconds and more, with only 5 threads doing
2 requests for the script. the load on webserv.com was huge during that
time, sometimes i even had to stop apache to end the test.
-- 
Edit bug report at http://bugs.php.net/?id=17044&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=17044&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=17044&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=17044&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=17044&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17044&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=17044&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=17044&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=17044&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=17044&r=globals

Reply via email to