php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47314 SoapClient leave tcp connections in "time_wait"
Submitted: 2009-02-05 13:33 UTC Modified: 2017-10-24 07:50 UTC
Votes:13
Avg. Score:4.8 ± 0.5
Reproduced:12 of 12 (100.0%)
Same Version:3 (25.0%)
Same OS:4 (33.3%)
From: bernd dot ott at k-m dot info Assigned:
Status: Open Package: SOAP related
PHP Version: 5.2CVS-2009-02-05 (snap) OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bernd dot ott at k-m dot info
New email:
PHP Version: OS:

 

 [2009-02-05 13:33 UTC] bernd dot ott at k-m dot info
Description:
------------
Call to a Soapserver with the SoapClient leaves after a function call tcp-connection in state "time_wait".

depending on your server your server get unreachable, because all workers are allocated by the waiting connections.

the sample code leaves 100 open connections.


if you call more than on function you get more open connections.
the soapclient doesnt reuse the open connection.
(this is not shown in the sample)

the connections you can see in netstat or tcpview (sysinternals)


Reproduce code:
---------------
Client:

<?php    
  $i=100;
  while ($i>0) {
   $sc = new SoapClient(null, array('location' => "http://localhost/server.php",
                                     'uri'      => "http://test-uri/"));
   echo $sc->__soapcall("test", array('test'))."\r\n";
   flush();
   
    $i -= 1;  
  }



Server:
<?php
function test($x)
{
    return $x."hallo";
}

$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction("test");
$server->handle();

Expected result:
----------------
Client opens connection, does the function call and terminates connection.

after correct close the should no connections in state "time_wait".

Actual result:
--------------
100 connections are in time_wait status.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-18 15:41 UTC] dmitry@php.net
According to http://tangentsoft.net/wskfaq/articles/debugging-tcp.html and http://www.developerweb.net/forum/showthread.php?t=2941 it's a normal TCP behaviour. (In case you run Apache benchmark you can see a lot of connections in TCP_WAIT state too)

In case you call SOAP functions on the same SoapClient object and your Web Server responds with keep-alive HTTP header all the functions will use a single TCP connection.
 [2009-02-23 11:11 UTC] bernd dot ott at k-m dot info
open the socket with fsocketopen / fclose doesnt leave timewait connections.

the problem is, this causes my .net soap server to a not response state. this is because all workers are allocated.

i cant use keep alive, my page is using ajax to a php page which contains the soapclient.
 [2009-02-23 11:21 UTC] pajoye@php.net
Do you have IPv6 installed (by default on Vista or later, needs an extra package for XP/2k). If yes, edit:

C:\windows\system32\drivers\etc\hosts

and comment the following line:

::1 localhost

becomes:

#::1 localhost

Restart the web server and test again.
 [2009-03-02 08:34 UTC] bernd dot ott at k-m dot info
i created the sample on a old xp machine with apache 2.2 installed.

i have tested the webservice with different Clients made with different languages. no other client keep the connections in "time_wait".
 [2009-05-02 02:49 UTC] jani@php.net
But did you do what Pierre asked above ? The hosts thing..
 [2009-05-05 09:08 UTC] bernd dot ott at k-m dot info
I don't have the ipv6 Stack installed (on any machine).
 [2009-07-20 11:20 UTC] m dot stach at ewerk dot com
We are experiencing the same problem. We use Debian Etch (64 bit) in 
combination with Sun Glassfish 2.1 on separate servers.
 [2010-03-25 13:48 UTC] bernd dot ott at k-m dot info
Maybe this will Help to solve the problem:
http://httpd.apache.org/docs/1.3/misc/fin_wait_2.html
 [2017-10-24 07:50 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: dmitry +Assigned To:
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC