Bug #81029 [NEW]: SOAP HTTP socket not closing on object destruction
From: kdonaldson at staff dot nexigen dot digital
Operating system: macOS and Cent OS 7
PHP version: 7.4.19
Package: SOAP related
Bug Type: Bug
Bug description:SOAP HTTP socket not closing on object destruction
Description:
------------
If a SoapClient object is constructed without specifying the
'keep_alive' option to false, the socket never appears to be closed if
it falls out of scope
The provided script should be able to reproduce this, you can check the
open sockets by running the script like: "php /path/to/script.php &" and
using the resulting PID on "lsof -a -p {pid}"
You should slowly see a list of TCP connections slowly build up over
time similar to this:
php 4396 vagrant 3u IPv4 53416 0t0 TCP
homestead:57814->ec2-52-7-155-169.compute-1.amazonaws.com:https
(ESTABLISHED)
php 4396 vagrant 4u IPv4 53447 0t0 TCP
homestead:57816->ec2-52-7-155-169.compute-1.amazonaws.com:https
(ESTABLISHED)
php 4396 vagrant 5u IPv4 54451 0t0 TCP
homestead:57818->ec2-52-7-155-169.compute-1.amazonaws.com:https
(ESTABLISHED)
If instead you were to add ['keep_alive' => false] as the options
parameter on the SoapClient you'll see that the TCP connections don't
appear to build up.
While I do understand the purpose of Keep Alive to keep a single
connection open, I would assume this is still a bug as the SoapClient
has gone out of scope and new SoapClient objects don't appear to reuse
the existing connection and simply ignore it creating a new one.
Test script:
---------------
<?php
function call(int $number) {
$client = new
SoapClient('https://www.dataaccess.com/webservicesserver/NumberConversion.wso?WSDL');
$response = $client->NumberToWords(['ubiNum' => $number]);
return $response->NumberToWordsResult;
}
$numbers = array_fill(0, 10000, 1);
foreach ($numbers as $number) {
call($number);
}
Expected result:
----------------
The socket to be closed when the SoapClient object falls out of scope or
destructs
Actual result:
--------------
The socket stays open and contributes to the open file limit / file
descriptor limit
--
Edit bug report at https://bugs.php.net/bug.php?id=81029&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81029&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81029&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81029&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81029&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81029&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81029&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81029&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81029&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81029&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81029&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81029&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81029&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81029&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81029&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81029&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81029&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81029&r=mysqlcfg
Thread (20 messages)
- kdonaldson at staff dot nexigen dot digital
- cmb@php.netBug #81029 [Opn]: SOAP HTTP socket not closing on object destruction
- nikic@php.netBug #81029 [Opn]: SOAP HTTP socket not closing on object destruction
- kimia dot salamsao9881 at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- johnsonsellen at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- jbriss at ebridge dot skBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- schamberumarcelo at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- insidestrongs at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- meghaagarwalbaniya at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- ammarloner at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- mikejohnarzona at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- venile2040 at dekaps dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- johnsonsellen at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- forseobirdawade at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- andrewsauder at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- owork138 at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- owork138 at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- emmaturner at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- sincerelyjulie0 at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction
- emmaturner at gmail dot comBug #81029 [Com]: SOAP HTTP socket not closing on object destruction