# Having a problem with DRb

**URL:** <https://www.ruby-forum.com/t/having-a-problem-with-drb/92047>\
**Category:** Ruby\
**Created:** [April 15, 2007, 7:55am UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047 "2007-04-15T07:55:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 15, 2007, 7:55am UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/1 "2007-04-15T07:55:33Z")

</div>

It won’t connect. I tried it with a friend 400 miles away, and I tried  
it on 2 comps here on my home network. I get a DRbConnError no matter  
what variation I try. Firewall off/on, port forwarding and port  
triggering off/on. The server and client snippets of relevance are  
below.

#SERVER  
  
$uri = “druby://localhost:7824”

if $0 == **FILE**  
theApp = FXApp.new  
$server = STCCGServer.new(theApp, “GameServer”)  
thr = Array.new  
thr \<\< Thread.new do  
theApp.create  
$server.show  
theApp.run  
end  
DRb.start\_service($uri, $server.game)  
thr \<\< DRb.thread  
thr.each{|thread| thread.join}  
end

#CLIENT  
  
$port = 7824  
join.connect(SEL\_COMMAND) do  
self.hide  
owner.name = namefield.text  
owner.game = DRbObject.new(nil, “druby://#{ipfield.text}:#{$port}”)  
File.open($deck\_dir + filefield.text.strip, “r”){|file|  
owner.game.add\_player(namefield.text, file.gets)}  
sleep(1) until owner.game.game\_start  
owner.make\_interface  
end

When I run the server and client on my machine, things work. When I run  
the client and server on seperate machines listed above, I get  
DRbConnError. Something so widely used like DRb must work, so I can  
only assume I’ve made an error somewhere and I have no idea what it is.

Thanks,  
Raj

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 15, 2007, 3:16pm UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/2 "2007-04-15T15:16:33Z")

</div>

On Sun, Apr 15, 2007 at 02:54:45PM +0900, Raj S. wrote:

> It won’t connect. I tried it with a friend 400 miles away, and I tried  
> it on 2 comps here on my home network. I get a DRbConnError no matter  
> what variation I try. Firewall off/on, port forwarding and port  
> triggering off/on. The server and client snippets of relevance are below.

You’ve missed out the most important bit, which is a description of your  
home network _and_ your friend’s network.

If both are on private IP addresses, and both have NAT firewalls between  
them and the Internet, then unless you’ve set up a VPN linking the two  
networks then it’s not going to be straightforward to implement, because  
DRb  
involves calls in both directions.

There are some details about how DRb works at  
[http://wiki.rubygarden.org/Ruby/page/show/DRbTutorial](http://wiki.rubygarden.org/Ruby/page/show/DRbTutorial)

> #Server  
>   
> $uri = “druby://localhost:7824”

That is never going to work between hosts, because you’ve explicitly  
told  
the server to listen on interface 127.0.0.1 (the loopback), which means  
that  
only other processes on the same host will be able to connect to it.

You could try:  
$uri = “druby://myhostname.example.com:7824”

That may work but only if both machines are _directly_ connected to the  
Internet with a public IP address (e.g. it’s a Windows machine with a  
USB-ADSL modem or a dial-up) _and_ both machines have a real hostname,  
as  
the hostname is used by one machine to contact the other.

If not, then you will have to do lots of frigs involving port forwarding  
_and_ name to IP mapping. It would be easier to set up an ssh tunnel  
between  
the two machines, and run DRb over that, since only one piece of  
port-forwarding would be neeed.

Regards,

Brian.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 16, 2007, 12:11am UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/3 "2007-04-16T00:11:17Z")

</div>

From: “Raj S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> be done quickly and efficiently (and then coded for automation) on a  
> windows machine. I don’t know how to automate VPN either, but on XP,  
> setting up VPN seems to take only 1 minute of clicking the mouse.

Hi,

I don’t know the legalities of this, but it may be possible to  
distribute the minimal set of cygwin binarires to provide ssh.

cygwin1.dll cygssl\*.dll openssl.exe ssh.exe (…etc?)

I’m not a lawyer, etc., so I could be wrong, but it seems like the  
license [Cygwin Licensing Terms](http://cygwin.com/licensing.html) would allow distributing  
a subset of the binaries without the whole installer.

Regards,

Bill

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 15, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/4 "2007-04-15T23:52:13Z")

</div>

Brian C. wrote:

> > If not, then you will have to do lots of frigs involving port forwarding  
> > _and_ name to IP mapping. It would be easier to set up an ssh tunnel between  
> > the two machines, and run DRb over that, since only one piece of  
> > port-forwarding would be neeed.
> > 
> > Regards,
> > 
> > Brian  
> > That all makes a good amount of sense. My follow up question would be  
> > that since I’m doing this on a WinXP machine, would it be easier for me  
> > to try the VPN route instead of setting up SSH tunneling? On \*nix it  
> > seems like ssh can be set up instantly, but I have no idea how it would  
> > be done quickly and efficiently (and then coded for automation) on a  
> > windows machine. I don’t know how to automate VPN either, but on XP,  
> > setting up VPN seems to take only 1 minute of clicking the mouse.

Raj

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 16, 2007, 6:36am UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/5 "2007-04-16T06:36:40Z")

</div>

Bill K. wrote:

> > be that since I’m doing this on a WinXP machine, would it be easier  
> > distribute the minimal set of cygwin binarires to provide ssh.  
> > Bill

I apologize for this having become a little off topic. Can anyone  
confirm what Bill is saying? How would I go about getting those  
specific binaries, and then how would I use them? Is there a way to  
integrate them with ruby. Could I create my own SSH gem or SSH module  
somehow?

Raj

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 16, 2007, 6:56am UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/6 "2007-04-16T06:56:41Z")

</div>

From: “Raj S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> > > That all makes a good amount of sense. My follow up question would  
> > > I don’t know the legalities of this, but it may be possible to  
> > > specific binaries, and then how would I use them? Is there a way to  
> > > integrate them with ruby. Could I create my own SSH gem or SSH module  
> > > somehow?

Note also that ruby already has Net::SSH:  
[http://rubyforge.org/projects/net-ssh/](http://rubyforge.org/projects/net-ssh/)

Maybe Net::SSH can even do port-forwarding… I don’t know, though.

Regards,

Bill

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 16, 2007, 12:35pm UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/7 "2007-04-16T12:35:12Z")

</div>

Raj S. wrote:

> I apologize for this having become a little off topic. Can anyone  
> confirm what Bill is saying? How would I go about getting those  
> specific binaries, and then how would I use them?

Go to the Cygwin homepage, and download the installer. Select what you  
need (a bit of familiarity with Linux wouldn’t hurt), and wait for the  
download and installation to complete.

You can then redistribute it as long as you confirm to the GPL (or write  
up installation instructions, if you don’t feel safe), and / or just  
redistribute the installer. It’s the GPL, so you should be safe if you  
don’t modify the Cygwin source and redistribute that.

> Is there a way to  
> integrate them with ruby. Could I create my own SSH gem or SSH module  
> somehow?

There’s already an SSH gem (gem install net-ssh). You need Cygwin only  
to setup an SSH server on your side, and don’t have to hack it up that  
much.

I have no idea, though, if this SSH server can interact with stuff  
outside of Cygwin, or if you have to compile Ruby within the Cygwin  
environment.

–  
Phillip “CynicalRyan” Gawlowski  
[http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
[http://clothred.rubyforge.org](http://clothred.rubyforge.org)

Rules of Open-Source Programming:

1. Backward compatibility is your worst enemy.

2. Backward compatibility is your users’ best friend.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 16, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/8 "2007-04-16T16:23:53Z")

</div>

On Mon, Apr 16, 2007 at 06:51:42AM +0900, Raj S. wrote:

> That all makes a good amount of sense. My follow up question would be  
> that since I’m doing this on a WinXP machine, would it be easier for me  
> to try the VPN route instead of setting up SSH tunneling?

If one end is WinXP and the other Unix, then run ‘putty.exe’ on the  
WinXP  
end. It does port forwarding.

If both ends are WinXP then it’s more difficult. A VPN solution like  
OpenVPN  
or TINC may suit you better.

Regards,

Brian.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [April 16, 2007, 2:18pm UTC](https://www.ruby-forum.com/t/having-a-problem-with-drb/92047/9 "2007-04-16T14:18:32Z")

</div>

On 4/16/07, Phillip G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You can then redistribute it as long as you confirm to the GPL (or write
> 
> 1. Backward compatibility is your worst enemy.
> 
> 2. Backward compatibility is your users’ best friend.

Ruby Net::SSH can do port forwarding,

[http://net-ssh.rubyforge.org/chapter-6.html](http://net-ssh.rubyforge.org/chapter-6.html)

Although I am not sure, if it will fit your needs.
