-
-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If whois server is down, try other addresses #584
Comments
@njh I was able to run the same query. Are you running an high volume of requests? You may have been throttled. |
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. I am now wondering if it is related to me using IPv6. This is what I found with
Do you have IPv6? I guess it is possible there is a problem with their IPv6 network / rate limiting. |
No, I believe I'm currently binding to an IPv4 address. |
Closing as not dependent by the library. |
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: 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 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. |
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
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. |
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
If one of the servers are down (for example Web browsers have tried to solve this problem using an approach called Happy Eyeballs / RFC8305.
It is a shame that ruby doesn't have a internal implementation to do this for you. |
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 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 whois = Whois::Client.new(:bind_host => "0.0.0.0") However it feels like a very hacky solution to the problem. |
I have discovered that Here is a revision that uses 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 |
Hi,
I am having trouble with timeouts when looking up some domains. I am slightly confused about what I might be doing differently/weirdly, because I would expect others to be having the same problem. Looking up using the
whois
CLI tool works fine.Code:
Result:
Ruby version:
Any advice on how to diagnose the problem further would be appreciated.
Thanks,
nick.
The text was updated successfully, but these errors were encountered: