0

在 ruby​​ 中运行 Net::HTTP 发布请求。我在 Ubuntu 中使用终端并收到以下错误消息:

SocketError: getaddrinfo: Name or service not known
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `initialize'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `open'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from /usr/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from /usr/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from /usr/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /usr/lib/ruby/1.9.1/net/http.rb:744:in `start'
from /usr/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /usr/lib/ruby/1.9.1/net/http.rb:1307:in `send_entity'
from /usr/lib/ruby/1.9.1/net/http.rb:1096:in `post'
from (irb):356
from /usr/bin/irb:12:in `<main>'

运行以下代码:

uri = @@url
http = Net::HTTP.new(uri)
response = http.post('/', @@str)
puts response
4

1 回答 1

0

“名称或服务未知”是当您无法解析给定域名或指定无法连接的 IP 地址时引发的套接字级别错误。如果不发布您尝试发布的 URL 和字符串,则没有其他信息可用。

于 2013-06-15T23:57:44.900 回答