DRbFire (Module)

In: lib/drb/drbfire.rb

DRb Firewall Protocol


It is assumed that you already know how to use DRb; if you don’t you’ll need to go read up on it and understand the basics of how it works before using DRbFire. DRbFire actually wraps the standard protocols that DRb uses, so generally anything that applies to them applies to DRbFire.

Basic Usage

Using DRbFire is quite simple, and can be summed up in four steps:

  1. Start with require ‘drb/drbfire‘.
  2. Use drbfire:// instead of druby:// when specifying the server url.
  3. When calling DRb.start_service on the client, specify the server’s uri as the uri (as opposed to the normal usage, which is to specify no uri).
  4. Specify the right configuration when calling DRb.start_service, specifically the role to use:
    On the server:DRbFire::ROLE => DRbFire::SERVER
    On the client:DRbFire::ROLE => DRbFire::CLIENT

So a simple server would look like:

  require 'drb/drbfire'

  front = ['a', 'b', 'c']
  DRb.start_service('drbfire://some.server.com:5555', front, DRbFire::ROLE => DRbFire::SERVER)

And a simple client:

  require 'drb/drbfire'

  DRb.start_service('drbfire://some.server.com:5555', nil, DRbFire::ROLE => DRbFire::CLIENT)
  DRbObject.new(nil, 'drbfire://some.server.com:5555').each do |e|
    p e

Advanced Usage

You can do some more interesting tricks with DRbFire, too:

Using SSL:To do this, you have to set the delegate in the configuration (on both the server and the client) using DRbFire::DELEGATE => DRb::DRbSSLSocket. Other DRb protcols may also work as delegates, but only the SSL protocol is tested.


  • DRbFire uses a 32-bit id space, meaning ids will wrap after approximately ~4.2 billion connections. If that’s a non-theoretical problem for you, and you tell me about it, I’ll figure out some way to fix it. It‘d be worth it just to find out that DRbFire is being used in such a mind-blowing fashion.
  • You‘re limited to one server per process at this point. You can have (and handle) as many clients as you want (well, ok, so I just said there’s really a limit somewhere around 4.2 billion. I’m trying to simplify here). Again, this is possible to deal with, but not something that I’ve needed at this point and not something I’m guessing is terribly common. Let me know if it’s a problem for you.


VERSION = [0, 1, 0]
  The current version.
ROLE = "#{self}::ROLE"
  The role configuration key.
SERVER = "#{self}::SERVER"
  The server role configuration value.
CLIENT = "#{self}::CLIENT"
  The client role configuration value.
  The delegate configuration key.