Hello, I have been playing with dRuby and am getting strange differences with
passing DRbUndumped-objects from a client machine to a DIFFERENT server and
calling methods on this object:
I wrote a small server that basically accepts an object and does something
with this (calling its instance method "name"):
#server code
require("drb")
class Server
def receiveSomething(job)
puts("receiving something")
puts job.name
end
end
DRb.start_service("druby://:1234",Server.new)
DRb.thread.join
The client code defines the class "Something" which has the instance method
"name". I want to pass an object of class "Something" to the server BY
REFERENCE, so I added "include DRbUndumped" in its definition:
#client code
require("drb")
class Something
include DRbUndumped
def name
return "MyName"
end
end
DRb.start_service
server=DRbObject.new(nil,'druby://localhost:1234')
server.receiveSomething(Something.new)
All goes well ONLY IF THE SERVER AND THE CLIENT ARE RUN FROM THE SAME MACHINE:
server output:
receiving something
MyName
If I start the server code on a DIFFERENT machine (same OS (slackware 10.2),
same ruby version (1.8.4)) and replace "localhost" with the server machine
name in the client code, the server gives as output:
receiving something
and the client crashes with this message:
(druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:733:in `open':
druby://localhost:32816 - #<Errno::ECONNREFUSED: Connection refused -
connect(2)> (DRb::DRbConnError)
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:726:in
`open'
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1186:in
`initialize'
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1166:in
`open'
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1082:in
`method_missing'
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1100:in
`with_friend'
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1081:in
`method_missing'
from (druby://ivon:1234) as.rb:5:in `receiveSomething'
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1552:in
`perform_without_block'
... 6 levels...
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1344:in
`initialize'
from (druby://ivon:1234) /usr/local/lib/ruby/1.8/drb/drb.rb:1624:in
`start_service'
from (druby://ivon:1234) as.rb:8
from ac.rb:10
I've tested all dRuby examples using DRbUndumped that I could find and they
all work on one machine, but crash when trying to use them on two different
machines (what's the point of having a distributed environment that works
only on one machine :-)).
My client code CAN find the server correctly when using two different machines
since it says "receiving something", so these errors have nothing to do with
firewall settings or something, problems start when calling methods on
objects that are passed by reference. Maybe there are some ruby security
settings that I have wrong, but I have no clue which ones.
All help is very appreciated, especially with working examples!
Greetings,
Geert Fannes.