|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79497 stream_socket_client() throws an unknown error sometimes with <1s timeout
Submitted: 2020-04-20 01:53 UTC Modified: -
From: joey dot cai at gmail dot com Assigned:
Status: Closed Package: OpenSSL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2020-04-20 01:53 UTC] joey dot cai at gmail dot com
stream_socket_client() can throw an unknown error when connection timeout is set to less than 1s due to a bug in php_openssl_subtract_timeval()

A PR has been raised 

Test script:

// To test, run `php socket_test.php 10000 0.9 | grep error`

Expected result:
No connection errors

Tested X connections(timeout=0.1) with in xs with 0 errors

Actual result:
failed in 0.0037751197814941s,, errstr=
failed in 0.0031719207763672s,, errstr=
failed in 0.0026381015777588s,, errstr=
failed in 0.0029230117797852s,, errstr=
failed in 0.0027728080749512s,, errstr=
Tested 2000 connections(timeout=0.9) with in 6.1318738460541s with 5 errors


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-20 08:27 UTC]
Automatic comment on behalf of
Log: Fix #79497: Fix php_openssl_subtract_timeval()
 [2020-04-20 08:27 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jun 06 20:03:36 2023 UTC