Comments (9)
@njh I was able to run the same query. Are you running an high volume of requests? You may have been throttled.
from whois.
No, I am not running a high volume of requests.
My 'production' script looks up 13 domains, with a 1 second pause between each one.
But I have this problem when running the one-off test too. On a different IP at a different time.
I am now wondering if it is related to me using IPv6. This is what I found with lsof -ni
:
TCP [2001:8b0:ffd5:3:xxxx]:64293->[2406:da00:ff00::34c9:6d7f]:nicname (SYN_SENT)
Do you have IPv6? I guess it is possible there is a problem with their IPv6 network / rate limiting.
from whois.
Do you have IPv6?
No, I believe I'm currently binding to an IPv4 address.
from whois.
Closing as not dependent by the library.
from whois.
Just been looking into this and it looks like Amazon's Registrar isn't responding to connections on port 43 when using IPv6. I have reported it on the AWS forum:
https://forums.aws.amazon.com/thread.jspa?threadID=317497
If you don't have IPv6, then ruby (or the OS?) won't attempt to connect to the IPv6 address, and happily connect to the working IPv4 address.
Would you accept a PR that switches from TCPSocket
to Net::TCPClient?
This would improve IPv4-only connections too, as if a registrar publishes multiple IP addresses in DNS (as most do), it will attempt each one in turn.
from whois.
Thanks for researching into it @njh! I'm not thrilled about the idea of introducing a dependency to a third party library, especially to circumvent a specific provider issue.
I am interested to explore other options.
Can I ask you how did you find this issue? In Ruby, you can pass a binding IP address to the TPC socket. This library supports it by using bind_host
.
c = Whois::Client.new(bind_host: "192.168.1.100")
Would you be able to test by binding the local IPv4 network? I will need to spend some time to determine who's responsible for choosing the IPv6 address over IPv4 when resolving the whois host.
from whois.
I started down this route because my personal domain checking script (that uses this gem) kept failing and timing out. I have IPv6 at home and on my VPS, so it took a while to realise that it was IPv6 related.
It is getting much better, but unfortunately it is not uncommon for some IPv6 networks and services to have periods of downtime. Partly because monitoring is in place for IPv4 but not IPv6.
However this improvement could have benefits for non-IPv6 users too. For example whois.verisign-grs.com
has two IPv4 addresses associated with it:
$ host whois.verisign-grs.com
whois.verisign-grs.com has address 192.30.45.30
whois.verisign-grs.com has address 192.34.234.30
whois.verisign-grs.com has IPv6 address 2620:74:20::30
whois.verisign-grs.com has IPv6 address 2620:74:21::30
If one of the servers are down (for example 192.30.45.30
), then it won't currently fail over to the other server (192.34.234.30
). It will just timeout after attempting the first IP address.
Web browsers have tried to solve this problem using an approach called Happy Eyeballs / RFC8305.
However I think something simpler should be possible for whois.
- Lookup the hostname in DNS
- Loop through each of the IP addresses returned
- Attempt to connect to port 43 for each address
- If successful, send request and return result
- If unsuccessful, timeout after a few seconds and move on to the next address
It is a shame that ruby doesn't have a internal implementation to do this for you.
But I will see if I can write some proof of concept code, to avoid adding an external dependency.
from whois.
This little proof of concept is working for me. It loops through each of the addresses for a hostname and stops when it gets a response:
def whois_request(address, domain)
result = nil
Socket.tcp(address, 43, connect_timeout: 5) do |sock|
sock.write("DOMAIN #{domain}\r\n")
result = sock.readlines
end
result
end
Resolv.each_address('whois.verisign-grs.com') do |address|
begin
puts "Trying: #{address}"
result = whois_request(address, 'aelius.com')
unless result.nil?
puts "Success! Read #{result.count} lines."
break
end
rescue Errno::ETIMEDOUT => exp
puts "Timed out while connecting to #{address}"
end
end
Note that it uses Socket.tcp()
instead of TCPSocket.new
because the later doesn't support setting a connect timeout. I think Socket.tcp()
was added in Ruby 2.x.
I did try your suggestion of binding the local socket to my IPv4 address and it does work as a workaround (thanks!). I even found that you can bind it to 0.0.0.0
to force IPv4 but not have to hard code a specific address:
whois = Whois::Client.new(:bind_host => "0.0.0.0")
However it feels like a very hacky solution to the problem.
from whois.
I have discovered that Resolv.each_address
doesn't respect operating system preferences (for example the configuration in /etc/gai.conf
).
Here is a revision that uses Addrinfo.foreach
instead, which attempts connections in the correct order:
def whois_request(addrinfo, domain)
result = nil
Socket.tcp(addrinfo.ip_address, addrinfo.ip_port, connect_timeout: 5) do |sock|
sock.write("DOMAIN #{domain}\r\n")
result = sock.readlines
end
result
end
Addrinfo.foreach("whois.verisign-grs.com", "whois", nil, Socket::SOCK_STREAM, Socket::IPPROTO_TCP).each do |addrinfo|
begin
puts "Trying: #{addrinfo.inspect}"
result = whois_request(addrinfo, 'aelius.com')
unless result.nil?
puts "Success! Read #{result.count} lines."
break
end
rescue Errno::ETIMEDOUT => exp
puts "Timed out while connecting to #{addrinfo.ip_address}"
end
end
from whois.
Related Issues (20)
- Set address of whois service HOT 2
- nameservers parsing issue
- .io parser is broken HOT 1
- Using this gem in a commercial setting HOT 1
- Bug with .cat TLD HOT 1
- querying a whois server via SOCKS proxy HOT 1
- Add .et Whois host HOT 1
- whois of unicode character .ā¤ā¤žā¤°ā¤¤ HOT 1
- Connection refused - connect(2) for "whois.reg.com" port 43 HOT 1
- Add .bgWhois host HOT 1
- Parse my /etc/whois.conf HOT 1
- Whois::ConnectionError: SocketError: getaddrinfo: nodename nor servname provided, or not known HOT 1
- Is possible use proxy? HOT 1
- What to do when hitting this error: "Unable to find a WHOIS server for `google.com' (Whois::ServerNotFound)" HOT 1
- Issue with whois.godaddy.com HOT 1
- why does whois gem timeout vs just running whois on the command line
- Whois Parser for .de (Germany) fails with Unexpected Token HOT 1
- The whois server for `.tv` needs an update
- How to detect if a record has changed? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whois.