celluloid / celluloid-io

UNMAINTAINED: See celluloid/celluloid#779 - Evented sockets for Celluloid actors
https://celluloid.io
MIT License
879 stars 93 forks source link

Errno::ENOENT: No such file or directory - Y:/etc/resolv.conf #64

Closed perlun closed 6 years ago

perlun commented 11 years ago

It seems like the Celluloid::IO DNS resolver is a bit Unix-only for the moment. This is what I get when trying to run it on JRuby for Windows (when using it with a DNS host name; specifying an IP address works correctly).

Errno::ENOENT: No such file or directory - Y:/etc/resolv.conf
        org/jruby/RubyFile.java:333:in `initialize'
        org/jruby/RubyIO.java:1179:in `open'
        org/jruby/RubyKernel.java:333:in `open'
        org/jruby/RubyIO.java:3611:in `read'
        org/jruby/RubyIO.java:3708:in `read'
        Y:/Work/Source/hg/eCraft.appFactory-2013.6/src/server/gems/jruby/1.9/gems/celluloid-io-0.14.0/lib/celluloid/io/dns_resolver.rb:19:in `nameservers'
        Y:/Work/Source/hg/eCraft.appFactory-2013.6/src/server/gems/jruby/1.9/gems/celluloid-io-0.14.0/lib/celluloid/io/dns_resolver.rb:36:in `initialize'
        Y:/Work/Source/hg/eCraft.appFactory-2013.6/src/server/gems/jruby/1.9/gems/celluloid-io-0.14.0/lib/celluloid/io/tcp_socket.rb:66:in `initialize'
        Y:/Work/Source/hg/eCraft.appFactory-2013.6/src/server/gems/jruby/1.9/gems/celluloid-websocket-client-0.0.1/lib/celluloid/websocket/client/connection.rb:
14:in `initialize'
perlun commented 11 years ago

Same problem with celluloid-io df768cd3cdb2 btw, so not yet fixed. Comment from @tarcieri:

https://github.com/celluloid/celluloid-io/blob/master/lib/celluloid/io/dns_resolver.rb#L22

perlun commented 11 years ago

@tarcieri: That's not really the same issue actually. It's this method that fails:

  def self.nameservers(config = RESOLV_CONF)
    File.read(config).scan(/^\s*nameserver\s+([0-9.:]+)/).flatten
  end

...which isn't really so weird since this is the value of RESOLV_CONF:

  RESOLV_CONF = '/etc/resolv.conf'

:-)

I looked at the code briefly and it seems like the reason why we need to find the DNS server ourself is since we are creating DNS requests manually (unsure of the exact reason for this). I wonder if it would be acceptable to just make Celluloid::IO::DNSResolver fall back to Resolv.getaddress if it runs on Windows? Of course, this presumes that https://github.com/jruby/jruby/issues/773 gets fixed first...

tarcieri commented 11 years ago

unsure of the exact reason for this). I wonder if it would be acceptable to just make Celluloid::IO::DNSResolver

This would create blocking I/O requests that hang the reactor

perlun commented 11 years ago

Good point, Tony. ;) How about this one? https://github.com/celluloid/celluloid-io/pull/65

I've tested it and it works correctly for me (JRuby 1.7.4, Java 1.7.0_10). Of course it would be better to do it even more cleanly, but this was the best I could accomplish for the time being. Given that the previous code is completely defunct on Windows, it's at least a step in the right direction...

(I also fixed the /etc/hosts to be read correctly on Windows, which was easier and less controversial.)

deadprogram commented 11 years ago

This problem also exists on Ruby 2.0 on Windows.

tarcieri commented 11 years ago

@deadprogram can you try celluloid-io 0.15.0.pre?

deadprogram commented 11 years ago

Still getting this error on Windows 7 with 0.15.0.pre:

E, [2013-08-26T18:19:38.940150 #2516] ERROR -- : No such file or directory - /etc/resolv.conf
tarcieri commented 11 years ago

Okay, time to re-evaluate something like #65

This probably won't make it out in Celluloid::IO 0.15.0 but we can try to get it into 0.15.1

perlun commented 11 years ago

Tony,

I'll see if I can find some time to look into it further (try to make #65 work on top of the latest master).

Best regards, Per

On Tue, Aug 27, 2013 at 5:22 AM, Tony Arcieri notifications@github.comwrote:

Okay, time to re-evaluate something like #65https://github.com/celluloid/celluloid-io/issues/65

This probably won't make it out in Celluloid::IO 0.15.0 but we can try to get it into 0.15.1

— Reply to this email directly or view it on GitHubhttps://github.com/celluloid/celluloid-io/issues/64#issuecomment-23309167 .

mvh, Per Lundberg

tarcieri commented 11 years ago

@perlun cool, thanks!

halorgium commented 10 years ago

http://apidock.com/ruby/v1_9_3_125/Win32/Resolv/get_resolv_info/class

tarcieri commented 10 years ago

@luislavena if we used Win32::Resolv.get_resolv_info here would that actually resolve this issue?

luislavena commented 10 years ago

@tarcieri Win32::Resolv (win32/resolv) uses the Windows registry to read nameserver information and the interfaces configurations.

I believe is a reliable mechanism on WIndows to perform the task required here.

tarcieri commented 10 years ago

@luislavena cool, thank you!

digitalextremist commented 9 years ago

How are we doing with this, since 11/13?

perlun commented 6 years ago

Age old, closing.