Bug #74888 [Csd->Nab]: Timeout never or randomly reached for TLS sockets
| From: | requinix@php.net | Date: | Tue, 11 Jul 2017 08:36:16 +0000 |
| Subject: | Bug #74888 [Csd->Nab]: Timeout never or randomly reached for TLS sockets | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209982@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74888&edit=1
ID: 74888
Updated by: requinix@php.net
Reported by: mmn at hethane dot se
Summary: Timeout never or randomly reached for TLS sockets
-Status: Closed
+Status: Not a bug
Type: Bug
Package: Streams related
Operating System: Ubuntu 16.04
PHP Version: 7.2.0alpha3
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2017-07-10 19:41:17] mmn at hethane dot se
closing as it was a bug in HTTP_Request2_SocketWrapper
------------------------------------------------------------------------
[2017-07-10 19:40:47] mmn at hethane dot se
It seems that this was a bug in HTTP_Request2 because they use 'fgets' instead of
'fread'!
Apologies for the disturbance. .)
------------------------------------------------------------------------
[2017-07-09 21:20:58] mmn at hethane dot se
Description:
------------
Hello I am using the PEAR HTTP_Request2 library in the software GNU social to make remote requests.
I have noticed recently a "malicious" remote server in our federated network that simply
replies _extremely_ slowly_ it seems.
This causes our background processes - which run in PHP - to stall whenever connecting to these
remote servers. For this reason, PHP has the default_socket_timeout=60, which should cause
connections to die relatively quickly (at least with double that specified timeout in seconds,
according to bug #48280 at least).
However, this does not seem to happen. The server in this case manages to keep alive connections
with socket timeout of 2 seconds for much longer than that. I don't know if it is related to
the timeout value - but it does _seem_ to be proportionate to the configured timeout (2 second
timeouts die faster than 10 second timeouts etc.).
With HTTP_Request2 this _only_ happens with the Socket adapter and not the Curl adapter (which
flawlessly hits the timeout on the millisecond) which leads me to believe it's the underlying
PHP sockets that have an issue here.
I'm thinking it could be related to bug #41631 that seems to have been a long-living issue with
TLS connections not respecting the socket timeout? This has so far only been experienced in HTTPS
connections in GNU social at least.
The below test script uses HTTP_Request2 as mentioned, https://pear.php.net/package/HTTP_Request2
(maybe requires some other PEAR stuff too)
Test script:
---------------
require('HTTP/Request2.php');
$r = new HTTP_Request2();
$r->setConfig(['connect_timeout'=>1, 'timeout'=>2]);
$r->setMethod($r::METHOD_POST);
foreach(['Thanks-For-Debugging: Really like it.'] as $header) { $r->setHeader($header);
}
$r->setUrl('https://hash.my/api/subscriptions/1234');
$time=time(); echo "$time\n"; try {$r->send();} catch(Exception $e){echo
get_class($e).': '.$e->getMessage();} echo "\nIt actually took:
".(time()-$time)." seconds\n";
Expected result:
----------------
HTTP_Request2_MessageException: Request timed out after 2 second(s)
It actually took: 2 seconds
Actual result:
--------------
HTTP_Request2_MessageException: Request timed out after 2 second(s)
It actually took: 48 seconds
(Note that the value where it says "after n second(s)" is just HTTP_Request2 reporting it
like that because it was my configured, desired, value.)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74888&edit=1