views:

60

answers:

1

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!

A: 

If accessing w3.org fails the test, then it can't be an IPv6 problem as w3.org is not IPv6 enabled yet. Proof:

$ host -t aaaa w3.org
w3.org has no AAAA record
$ host -t aaaa www.w3.org
www.w3.org has no AAAA record

So no, Ruby on Windows is not failing when dealing with IPv6. Well, maybe sort of, but it’s failing when dealing with IPv4 too. As you said yourself in the comments, the test fails regardless of address. If that’s the case, how is this an “IPv6 issue”? Misdiagnosis, I suspect.

You made a function name called test_ipv6_connection() but all you’re calling is Net::HTTP.new() — hardly an IPv6–specific function. I am really stumped as to how IPv6 got blamed at all here.

Jeremy Visser
I'm as stumped as you are, but that seems to be the only explanation anyone can offer (however, although the endpoint in this case is not IPv6-enabled, the network I am on is). Although again, it's only happening on Windows Server 2008 R2, not on various IPv6-enabled Windows 7 machines within the same network.
Edd Morgan