php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12802 gethostbyname/gethostbyaddr timeout
Submitted: 2001-08-16 21:03 UTC Modified: 2021-05-23 04:23 UTC
Votes:72
Avg. Score:4.7 ± 0.8
Reproduced:62 of 64 (96.9%)
Same Version:18 (29.0%)
Same OS:31 (50.0%)
From: cheapsalsa at yahoo dot com Assigned:
Status: Wont fix Package: Network related
PHP Version: * 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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cheapsalsa at yahoo dot com
New email:
PHP Version: OS:

 

 [2001-08-16 21:03 UTC] cheapsalsa at yahoo dot com
I propose creating a timeout argument on the gethostbyname and gethostbyaddr.  I have a script that uses these, and if my internet connection goes down it takes 1:30-2:00 minutes for 3 gethostbyname's to timeout.  This is way to long, and it would help if I could specify a timeout.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-05 06:19 UTC] sergi at millorsoft dot es
Is this bug still open? I think it's a really important bug and can cause very long retards when the DNS lookup doesn't respond or some DNS server is unreacheable.
 [2003-08-10 22:54 UTC] grimtraffic at hotmail dot com
To be honest, no timeout has really made it hard to log users. There is no point of logging IP's because they change too often for dial-up users, and with my page timing out every third time someone goes to it, I now have troubles. 
By the way, 2 out of 3 who use gethostbyaddr have an issue with it timing out constantly.
 [2009-03-04 19:19 UTC] adifranco at tagged dot com
Any intent to fix this?  This kind of indeterminism is very crippling to trying to use these functions in a feature that interacts with the user.
 [2010-03-04 16:34 UTC] tyra3l at gmail dot com
bump
 [2010-11-19 00:05 UTC] pajoye@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2010-11-19 00:05 UTC] pajoye@php.net
For the record, it is not possible to do it in PHP. These functions are implemented by the operating systems. Without creating a thread for the get* hosts, we won't have any control on the timeout.
 [2010-11-19 00:53 UTC] tyra3l at gmail dot com
maybe we could use some non-blocking dns library?
http://c-ares.haxx.se/

Tyrael
 [2010-11-19 01:07 UTC] pajoye@php.net
-Status: Open +Status: Assigned -Operating System: Linux (N/A) +Operating System: -Assigned To: +Assigned To: pajoye
 [2010-11-19 01:07 UTC] pajoye@php.net
We have an implementation, only a matter of using it instead of get*. I have some patch for that, adding some features for the DNS APIs. It should be easy to modify this function while being at it.
 [2010-11-19 01:37 UTC] tyra3l at gmail dot com
can I access that implementation from userspace right now?
if there is a way, then it's fine for me as is, but I wouldn't dare to change the 
current implementation of those functions.
so maybe the best would be to add new userspace functions for the async behaviour.

Tyrael
 [2010-11-19 02:06 UTC] pajoye@php.net
-PHP Version: 4.0CVS-2001-08-16 +PHP Version: *
 [2010-11-19 02:06 UTC] pajoye@php.net
It will be available when committed.
 [2012-09-25 12:34 UTC] tyrael@php.net
any progress on this?
 [2013-08-22 02:50 UTC] zach dot bailey at pardot dot com
Please, please, please consider adding this. It's a huge scalability/performance 
issue anytime a call out to an external service is not bounded with a timeout. PHP 
users are having to resort to ridiculous workarounds to something that should be 
built into the core language. It's unfathomable that PHP has functions like the 
ability to get the time that the sun will rise for a certain date and location but 
it can't be bothered with having a timeout on an extremely common function.
 [2016-08-15 18:17 UTC] toddww at gmail dot com
10+ years later ??? Come on.
 [2017-07-24 20:52 UTC] kalle@php.net
@Pierre wouldn't this be possible on the Windows side of things using GetAddrInfoEx() function? I'm not sure about the Unix counterpart tho, and I guess threads are out of the questions
 [2017-10-23 00:03 UTC] kalle@php.net
-Status: Assigned +Status: Open -Operating System: +Operating System: * -Assigned To: pajoye +Assigned To:
 [2018-02-11 17:48 UTC] cmb@php.net
-Package: *General Issues +Package: Network related
 [2021-05-23 04:23 UTC] krakjoe@php.net
-Status: Open +Status: Wont fix
 [2021-05-23 04:23 UTC] krakjoe@php.net
20 years is long enough to keep anyone on the hook ...

A portable implementation of these things is a project all it's own - one of them is called c-ares and is developed by cURL. While it's well known and has a nice API, it's not realistic to talk about making that a build requirement of PHP.

The core implementation of these things should rely on stable operating system provided functionality, and not third party libraries.

I think at some time in the past, it may have been realistic to consider redeveloping this functionality ... those days have long gone.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 16:01:29 2024 UTC