On May 16, 2006, at 12:25 PM, cremes.devlist / mac.com wrote:

> I've been tearing my hair out the last few days trying to track  
> down a bug in a gem that turns out to live in DRb. The gem is  
> 'reliable-msg' and it relies on DRb for rpc (I've cc'ed the author  
> too).
>
> I am not a good enough rubyist to track the problem all the way to  
> its true source, but I do have a simple test case to reproduce the  
> bug. Plus, there's a simple work around (look at the comments in  
> the server sample code).
>
> As near as I can tell, this only breaks on OSX (OSX 10.4.6, ruby  
> 1.8.4, DRb 2.0.4).
>
> The error concerns ACL handling and how 127.0.0.1/localhost is  
> interpreted (maybe an ipv6 prob?). Doing a 'netstat -an|grep 9000'  
> while the following code is run shows:
> tcp6       0      0  ::1.9000               *.*                     
> LISTEN

IPv6 can be the bane of your existence.  Setting up proper name  
service for it is not fun.

If you're only going to be talking over loopback you may want to  
switch to UNIX sockets.

> With apologies to Eric Hodel from whom I borrowed some code, here  
> are the samples:
>
> ------ SERVER --------
> #!/usr/bin/env ruby -w
> # simple_service.rb
> # A simple DRb service
>
> # load DRb
> require 'drb'
> require 'drb/acl'
>
> # start up the DRb service
> DRb.start_service   'druby://localhost:9000',

You can change this to 'druby://127.0.0.1:9000', that will force it  
to use IPv4.

>                     [],
>                     :tcp_acl => ACL.new('allow 127.0.0.1'.split("  
> "), ACL::ALLOW_DENY) # <-- causes failure
>                     #:tcp_acl => ACL.new('allow localhost'.split("  
> "), ACL::ALLOW_DENY)  <-- works
>                     # works if you replace 127.0.0.1 with localhost

DRb chose to listen on the IPv6 socket, so you'll need to allow both  
127.0.0.1 and ::1 or just use localhost.

You could also try removing ::1 localhost from /etc/hosts, that might  
fix it.

> # wait for the DRb service to finish before exiting
> DRb.thread.join
> -------------
>
> The error displayed by the client is:
>
> ~/developer/projects/ruby/bugs/drb-acl cremes$ ruby -w  
> simple_client.rb druby://localhost:9000
> /opt/local/lib/ruby/1.8/drb/drb.rb:567:in `load': connection closed  
> (DRb::DRbConnError)

I bet the connection came from ::1:9000 so DRb closed the connection.

-- 
Eric Hodel - drbrain / segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com