joepie91 / python-whois

A python module for retrieving and parsing WHOIS data
Do What The F*ck You Want To Public License
399 stars 187 forks source link

Frequent timeouts using pythonwhois #124

Open hserus1477 opened 8 years ago

hserus1477 commented 8 years ago

Hi - I (repeatably, as of the past few minutes) get timeouts even querying popular domain names like say icloud.com - and when I execute the same command from my command line whois client, I get the whois instantaneously. Thanks for a fix - maybe you could also call the command line whois tool here (https://github.com/rfc1036/whois) and parse its output? Thanks.

domain = ('icloud.com') :> details=pythonwhois.get_whois(domain)

Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.7/site-packages/pythonwhois/init.py", line 4, in get_whois raw_data, server_list = net.get_whois_raw(domain, with_server_list=True) File "/Library/Python/2.7/site-packages/pythonwhois/net.py", line 69, in get_whois_raw return get_whois_raw(domain, referal_server, new_list, server_list=server_list, with_server_list=with_server_list) File "/Library/Python/2.7/site-packages/pythonwhois/net.py", line 69, in get_whois_raw return get_whois_raw(domain, referal_server, new_list, server_list=server_list, with_server_list=with_server_list) File "/Library/Python/2.7/site-packages/pythonwhois/net.py", line 44, in get_whois_raw response = whois_request(request_domain, target_server) File "/Library/Python/2.7/site-packages/pythonwhois/net.py", line 86, in whois_request sock.connect((server, port)) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 60] Operation timed out

Sir-Fenrir commented 8 years ago

This is because the WHOIS response for icloud.com contains a referral link to an inactive server. It tries to obtain data from this inactive server, which obviously does not respond. On my develop branch https://github.com/MasterFenrir/python-whois/tree/develop this issue is fixed. It checks whether a referral server is alive or not before querying it.

cristianocca commented 7 years ago

Hello, is this issue already part of the current version? I'm wondering if there's a way to also define some kind of timeout, the default one seems too high for some use cases.