Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net::HTTP can't bind to ipv6 address #3531

Open
mohamedhafez opened this issue Dec 10, 2015 · 0 comments
Open

Net::HTTP can't bind to ipv6 address #3531

mohamedhafez opened this issue Dec 10, 2015 · 0 comments

Comments

@mohamedhafez
Copy link
Contributor

The following code works on MRI 2.2.1, but fails with Errno::ENETUNREACH every time on JRuby 9.0.4.0:

require "net/http"
require "uri"

uri = URI.parse('http://icanhazip.com/')
request = Net::HTTP::Get.new(uri.request_uri)
net_http = Net::HTTP.new(uri.host, uri.port)
net_http.local_host = "<your ipv6 address>"  #in my particular case "2607:5300:60:5fae::"
net_http.request(request).body

here's the stack trace I get:

Errno::ENETUNREACH: Network is unreachable - No message available
    from org/jruby/ext/socket/RubyTCPSocket.java:138:in `initialize'
    from org/jruby/RubyIO.java:1123:in `open'
    from /usr/local/rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:883:in `block in connect'
    from org/jruby/ext/timeout/Timeout.java:128:in `timeout'
    from /usr/local/rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:882:in `connect'
    from /usr/local/rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:867:in `do_start'
    from /usr/local/rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:856:in `start'
    from /usr/local/rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/http.rb:1389:in `request'
    from (irb):8:in `<eval>'
    from org/jruby/RubyKernel.java:978:in `eval'
    from org/jruby/RubyKernel.java:1291:in `loop'
    from org/jruby/RubyKernel.java:1098:in `catch'
    from org/jruby/RubyKernel.java:1098:in `catch'
    from /usr/local/rvm/rubies/jruby-9.0.4.0/bin/irb:13:in `<top>'

(not sure if it matters but I'm running ubuntu 12.04 with both ipv4 and ipv6 addresses)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant