Forum: Ruby dRuby connection refused between two different machines

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Geert F. (Guest)
on 2006-05-05 15:28
(Received via mailing list)
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 F..
Ross B. (Guest)
on 2006-05-05 16:48
(Received via mailing list)
On Fri, 2006-05-05 at 20:27 +0900, Geert F. wrote:
> 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:
>  [... snipped ...]
> 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)

Two possibilities you might check:

1) Are the proper ports open on both machines? Is the firewall setup
right (maybe a bit obvious, sorry if you've already checked that)?

2) Did you call DRb.start_service in the *client* as well as the server,
which you need to do for certain types of DRbUndumped callback stuff. I
think you can usually just call it without any arguments at the client
side.

Hope that helps,
Jamey C. (Guest)
on 2006-05-05 17:19
(Received via mailing list)
Geert F. wrote:
> connect(2)> (DRb::DRbConnError)
>
I had a similar problem about 6 months ago and ... crap!  I can't
remember what I did to fix it!

I seem to remember having to change something in the /etc/hosts file on
my client pc to get it to work.  Sorry I can't be more specific; I think
the brain cells that were holding that memory must have died off.

If I can remember what I did, I will email you.

Jamey C.

Confidentiality Notice: This email message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and/or privileged information. If you are not the intended
recipient(s), you are hereby notified that any dissemination,
unauthorized review, use, disclosure or distribution of this email and
any materials contained in any attachments is prohibited. If you receive
this message in error, or are not the intended recipient(s), please
immediately notify the sender by email and destroy all copies of the
original message, including attachments.
Eric H. (Guest)
on 2006-05-05 21:57
(Received via mailing list)
On May 5, 2006, at 4:27 AM, Geert F. wrote:

> 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:

You're telling the client to connect back to the local machine.

> #client code
> [...]
> server=DRbObject.new(nil,'druby://localhost:1234')
                             ^^^^^^^^^^^^^^^^^^^^^^^

--
Eric H. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Geert F. (Guest)
on 2006-05-05 23:24
(Received via mailing list)
I did replace the localhost with the server machine hostname, as I wrote
furtheron in my original mail:

"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:"

Anyway, the client can connect to the server since the server wrote
"receiving something". It must be something else.

Greetings,
Geert.
Geert F. (Guest)
on 2006-05-05 23:28
(Received via mailing list)
Do you remember if you had problems connecting to the server machine
(since I CAN connect to the server since the server writes out
"receiving something" when I call the receiveSomething method from the
client). My problem occurs when passing object by reference to different
machines and calling methods on this object.
Greetings,
Geert.
Geert F. (Guest)
on 2006-05-06 00:08
(Received via mailing list)
>Two possibilities you might check:
>
>1) Are the proper ports open on both machines? Is the firewall setup
>right (maybe a bit obvious, sorry if you've already checked that)?

The client can connect to the server since the server writes out
"receiving something" when the client calls the "receiveSomething"
method

>2) Did you call DRb.start_service in the *client* as well as the server,
>which you need to do for certain types of DRbUndumped callback stuff. I
>think you can usually just call it without any arguments at the client
>side.

As you can see in the example code, DRb.start_service is called for both
the server and client
Eric H. (Guest)
on 2006-05-06 00:42
(Received via mailing list)
On May 5, 2006, at 12:22 PM, Geert F. wrote:

>>> passing DRbUndumped-objects from a client machine to a DIFFERENT
> I did replace the localhost with the server machine hostname, as I
> wrote furtheron in my original mail:
>
> "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:"

In the future please give exactly the code that is broken.

> Anyway, the client can connect to the server since the server wrote
> "receiving something". It must be something else.

Then likely your second machine doesn't have a hostname set.  Check
your DNS for both machines, forward and reverse.

--
Eric H. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Pit C. (Guest)
on 2006-05-06 13:42
(Received via mailing list)
Geert F. schrieb:
> The client can connect to the server since the server writes out
> "receiving something" when the client calls the "receiveSomething"
> method

Geert, I'm no DRb specialist, but I think in your case the server needs
to be able to talk to the client, too. You should check that also.

Regards,
Pit
This topic is locked and can not be replied to.