ECONNRESET (Whois::ConnectionError) - 尝试在 Ruby 中查询 Whois 时出错

发布于 2024-11-03 19:28:55 字数 1239 浏览 2 评论 0原文

我正在用 Ruby 编写一个简单的程序来检查域列表是否已被占用。基本上它循环遍历列表,并使用以下函数进行检查。

require 'rubygems'
require 'whois'

def check_domain(domain)
  c = Whois::Client.new
  c.query("google.com").available?
end

该程序不断出错(即使我在 google.com 中进行硬编码),并打印下面的消息。鉴于该程序非常简单,我已经没有想法了 - 有什么建议吗?

/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:165:in `query_the_socket': Errno::ECONNRESET: Connection reset by peer (Whois::ConnectionError)
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/verisign.rb:41:in `request'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:113:in `query'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:150:in `buffer_start'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:112:in `query'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/client.rb:90:in `query'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:62:in `timeout'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/client.rb:87:in `query'
from checker.rb:7:in `check_domain'
from checker.rb:14
from checker.rb:11:in `each'
from checker.rb:11

I'm writing a simple program in Ruby to check if a list of domains is taken. Basically it cycles through a list, and uses the following function to check.

require 'rubygems'
require 'whois'

def check_domain(domain)
  c = Whois::Client.new
  c.query("google.com").available?
end

The program keeps erroring out (even when I hardcode in google.com), and prints the message below. Given how simple the program is, I've run out of ideas - any suggestions?

/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:165:in `query_the_socket': Errno::ECONNRESET: Connection reset by peer (Whois::ConnectionError)
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/verisign.rb:41:in `request'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:113:in `query'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:150:in `buffer_start'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:112:in `query'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/client.rb:90:in `query'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:62:in `timeout'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/client.rb:87:in `query'
from checker.rb:7:in `check_domain'
from checker.rb:14
from checker.rb:11:in `each'
from checker.rb:11

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我纯我任性 2024-11-10 19:28:55

对此问题有两种可能的解释:

  1. 您位于防火墙/代理后面,并且客户端无法到达服务器
  2. (更现实)您的请求被限制。某些 .COM 服务器(例如 GoDaddy)用于重置连接,以防止多次查询。请参阅此票证。您可以通过限制对同一服务器的请求数量来解决此问题。

The are two possible explanations to this issue:

  1. you are behind a firewall/proxy and the client can't reach the server
  2. (more realistic) your request is being throttled. Some .COM servers, such as GoDaddy, are used to reset the connection as a way to protect against multiple queries. See this ticket. You can solve this problem by limiting the number of requests to the same server.
十雾 2024-11-10 19:28:55

尝试使用 timeout 参数:

irb(main):002:0> c = Whois::Client.new(:timeout => 100) # 100 seconds
irb(main):003:0> c.query("google.com").available?
=> true

Try to use the timeout param:

irb(main):002:0> c = Whois::Client.new(:timeout => 100) # 100 seconds
irb(main):003:0> c.query("google.com").available?
=> true
空心空情空意 2024-11-10 19:28:55

以前有用吗?
您向 whois 服务器发出过多请求。减速。

之前没有工作吗?
您无法访问 whois 服务器

Was it working before?
You are making too many requests to whois server. Slow down.

Was not working before?
You can't reach whois server

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文