weppos / whois

An intelligent — pure Ruby — WHOIS client and parser.
https://whoisrb.org
MIT License
1.11k stars 282 forks source link

why does whois gem timeout vs just running whois on the command line #652

Open jtoy opened 1 year ago

jtoy commented 1 year ago

I have a simple script I am testing and I always get timeout errors for 99% of my whois lookups, but if I run whois from the command line I get back results immediately. How do I change my script to work more like the commandline whois utility and not timeout? here is my script:

require 'whois-parser'
words = %w[hello world]
second =  %w[word world hello]
#who = Whois.whois(:timeout => 5)
words.each do |w|
  second.each do |s|
    d = "#{w}#{s}.com"
    puts d
    begin
      r = Whois.whois(d)
      p = r.parser
      if p.available? 
        puts "#{d} AVAILABLE"
      else
        puts "#{d} NOT available"
      end
    rescue Timeout::Error  => e
      puts "timeout on lookup #{d}"
    end
  end
end

and the results I get:

helloword.com
timeout on lookup helloword.com
helloworld.com
timeout on lookup helloworld.com
hellohello.com
hellohello.com NOT available
worldword.com
timeout on lookup worldword.com
worldworld.com
worldworld.com NOT available
worldhello.com
worldhello.com NOT available