php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joey dot cai at gmail dot com
New email:
PHP Version: OS:

 

 [2020-04-20 01:53 UTC] joey dot cai at gmail dot com
Description:
------------
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 https://github.com/php/php-src/pull/5422 

Test script:
---------------
https://gist.github.com/joec4i/ef1b1156ed79e23487400c68a5f693cb

// 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, error.no=0, errstr=
failed in 0.0031719207763672s, error.no=0, errstr=
failed in 0.0026381015777588s, error.no=0, errstr=
failed in 0.0029230117797852s, error.no=0, errstr=
failed in 0.0027728080749512s, error.no=0, errstr=
Tested 2000 connections(timeout=0.9) with in 6.1318738460541s with 5 errors

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-20 08:27 UTC] nikic@php.net
Automatic comment on behalf of joe.cai@bigcommerce.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=94e09bfe558656d3f1470dc960b900a951b0dffc
Log: Fix #79497: Fix php_openssl_subtract_timeval()
 [2020-04-20 08:27 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 30 20:01:29 2025 UTC