Can't run both server and clients from the same script.

16 views
Skip to first unread message

Tasos Laskos

unread,
Sep 10, 2011, 3:40:07 PM9/10/11
to ruby-brb
Hi,

I've only been using BrB for a few hours now (great job btw) and I
think I've found a problem.

Long story short, my goal is to build a Grid of servers; that requires
servers to be able to also act as clients in order to gather
information about their peers (the rest of the servers/nodes).

However, it seems that when a Tunnel is instantiated before starting
the Reactor, instead of it blocking indefinitely it returns
immediately.

Here's some code that reproduces the problem:

brb_grid.rb:
--------------------
require 'brb'

port = ARGV.shift

if neighbour = ARGV.shift
puts ::BrB::Tunnel.create( nil, neighbour ).hello_block
end

public
def hello
'hello'
end

::EM::run do
::BrB::Service.start_service(
:object => self,
:host => 'localhost',
:port => port,
:verbose => true
)
end
--------------------

On one terminal:
ruby brb_grid.rb 1111

On a different terminal:
ruby brb_grid.rb 2222 brb://localhost:1111

The second terminal will output 'hello', the BrB service will run but
then the script will return immediately instead of blocking.

I'm new to EM so I may be missing something here, any ideas?

Cheers,
Tasos L.

Guillaume Luccisano

unread,
Sep 12, 2011, 2:15:36 PM9/12/11
to ruby...@googlegroups.com
Hi,

Sorry for the delay.
So yes the EM reactor never return, long time I haven't use BrB, but I used it in the past with a server connection to client too, it's just a matter of doing it after you init the service on the server, look at the example in the git repo!

2011/9/10 Tasos Laskos <tasos....@gmail.com>

Tasos Laskos

unread,
Sep 13, 2011, 6:29:25 AM9/13/11
to ruby...@googlegroups.com, Guillaume Luccisano
Hi,

The examples at the repo show a basic client-> server configuration with
the client and the server being in 2 different systems.
Can you give me an example of what you are talking about please?

Just to clarify:
I'm trying to have servers that can connect to other servers (i.e. the
servers will also act as clients to other servers),
however the first RPC call kills the local BrB::Service.

On 09/12/2011 09:15 PM, Guillaume Luccisano wrote:
> Hi,
>
> Sorry for the delay.
> So yes the EM reactor never return, long time I haven't use BrB, but I
> used it in the past with a server connection to client too, it's just
> a matter of doing it after you init the service on the server, look at
> the example in the git repo!
>
> 2011/9/10 Tasos Laskos <tasos....@gmail.com

> <mailto:tasos....@gmail.com>>

Reply all
Reply to author
Forward
0 new messages