So I've got a tool that I built in Ruby that uses net/http
to make some requests to an external REST service. I built and unit tested this tool using Windows 7 and it worked absolutely fine.
Now, since this tool is meant to be run periodically on one of our servers (running Windows Server 2008 R2), I deployed it there and suddenly it's failing with the following exception:
SocketError: getaddrinfo: The storage control blocks were destroyed.
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `initialize'
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `open'
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `connect'
C:/Ruby187/lib/ruby/1.8/timeout.rb:53:in `timeout'
C:/Ruby187/lib/ruby/1.8/timeout.rb:93:in `timeout'
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `connect'
C:/Ruby187/lib/ruby/1.8/net/http.rb:553:in `do_start'
C:/Ruby187/lib/ruby/1.8/net/http.rb:542:in `start'
C:/Ruby187/lib/ruby/1.8/net/http.rb:1035:in `request'
C:/Ruby187/lib/ruby/1.8/net/http.rb:772:in `get'
...
A bit of Googling reveals that this may be an issue with Ruby failing when dealing with IPv6 on a Windows machine. However: it works fine on this Windows 7 machine which has the full IPv6 stack enabled, is connected to the same network and even has the exact same installation of Ruby as the 2K8 server that fails with that error message.
The following is the simplest test case that fails (errors out with the above exception) on Windows Server 2008 but passes on Windows 7:
require "test/unit"
require "net/http"
class IPV6OnWindowsTest < Test::Unit::TestCase
def test_ipv6_connection
http = Net::HTTP.new('w3.org', 80)
response, result = http.get("/", nil)
assert_not_nil result
end
end
Remember, using identical Ruby 1.8.7 installations -- also occurs with 1.8.6 and 1.9.1, by the way.
Is there anyone out there that can suggest what I might be doing wrong here?
Since these two machines share a lot of properties yet one passes and one fails, I'm finding it hard to believe the conventional wisdom which attributes this to Ruby's inability to handle IPv6 on Windows.
Thanks in advance!