MPCodeWriter21 / whois21

whois21 is a simple and easy to use python package that lets you easily query whois information of a domain/IP.
Apache License 2.0
26 stars 1 forks source link

Timeout does not work #9

Open rshibanov opened 8 months ago

rshibanov commented 8 months ago

If I try to run this code from the network where whois port blocked, I don't get an Timeout error or any similar error.

import whois21
whois = whois21.WHOIS("google.com",timeout=10)
print(whois)

I tried decreasing the timeout value, but it did not help.

 whois21 -v --timeout 3 google.com
[14:54:50] [INFO] Looking up google.com...
[14:54:50] [DEBUG] Connecting to whois.iana.org:43...
^C[14:56:22] [ERROR] KeyboardInterrupt: Exiting...
MPCodeWriter21 commented 8 months ago

Hello @rshibanov,

Thanks for raising this issue! I've looked into it, and you can check the error property of the WHOIS class for more info on the last error:

import whois21

# WHOIS lookup with a specified timeout
whois = whois21.WHOIS("google.com", timeout=0.01)
print(whois.error)
# ('Error receiving data from "com.whois-servers.net": TimeoutError: timed out', TimeoutError('timed out'))

The error property contains the error message and exception object. I'm also thinking about adding an errors property in future updates and in that case error property might get deprecated.

If you have more feedback or run into other issues, let me know, and include your OS, Python version, and whois21 version.

Thanks again for helping improve whois21!