DRb Connection Closed Error?!?!?!?

K

Ken Hilton

Greetings,

Can anyone explain to me why this very simple little DRb client server pair
generates a DRb::DRbConnError when the client terminates? I've checked out
the books and the samples and I can't see what I'm missing. I'm running
Ruby 1.8.1 on Win2000 and WinXP. The problem reproduces w/the pair running
on the same machine or (with the host id modified) when each is running on
separate machines.

Instructions: Run drbsvr.rb first, then run the drbclnt.rb. The output I
get from ruby follows below.

PS. I am unable to rescue the error that was raised by DRb, which BTW
puzzles me further.

Thanks for any help you can lend.

Ken.

-----------------------------
# drb server

require 'drb'

class MySvr
def svc
puts "MySvr::svc called."
return "Service completed."
end
end

$stdout.sync=true;

while true
begin
puts "Starting MySvr..."
DRb.start_service("druby://localhost:9000", MySvr.new());
DRb.thread.join;
DRb.stop_service;
rescue DRb::DRbConnError
puts "Rescued DRbConnectionClosed: #{$!}"
end
end

------------------------
# drb client
require 'drb'

DRb.start_service(nil,nil);
svr = DRbObject.new(nil, "druby://localhost:9000")
10.times do
puts svr.svc();
end
DRb.stop_service;
---------------------------
Output:(rdb:1) c
Starting MySvr...
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:104: `connection closed'
(DRb::D
RbConnError)
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:596:in `start'
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:596:in `run'
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:549:in
`initialize'

from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:737:in `new'
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:737:in
`start_servi
ce'
from H:/qbbpo/src/vendornet/etc/drbsvr.rb:17
e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:104:
raise(DRbConnError, 'c
onnection closed') if sz.nil?
(rdb:3)
 
J

Joel VanderWerf

Ken said:
Greetings,

Can anyone explain to me why this very simple little DRb client server pair
generates a DRb::DRbConnError when the client terminates? I've checked out
the books and the samples and I can't see what I'm missing. I'm running
Ruby 1.8.1 on Win2000 and WinXP. The problem reproduces w/the pair running
on the same machine or (with the host id modified) when each is running on
separate machines.

I realize this is not much help to you, but it works fine on linux, with
either 1.8.1 or 1.9.0.
 
K

Ken Hilton

I figured as much. This is the second window's specific issue I've
uncovered since upgrading to 1.8.1. Hopefully one of the WinRuby wizards
out there will have an idea. Thx! :)

Ken.
 
D

daz

Ken said:
I figured as much. This is the second window's specific issue I've
uncovered since upgrading to 1.8.1. Hopefully one of the WinRuby wizards
out there will have an idea. Thx! :)

Ken.

Works for me, too on Win98se (Ruby 1.8.0 & 1.9.0).

The DRb::DRbConnError must be happening on the client side -
try a rescue there.

-----

While you're delving in this area, I see that William Webber has
profusely documented the dRuby 2.0.4 source code -- same version as you have
but now three times the size !!
http://www.ruby-lang.org/cgi-bin/cv...b/drb.rb?rev=1.11.2.5;content-type=text/plain


Cheers,

daz
 
K

Ken Hilton

I upgraded Win Ruby's DRb to the very latest version and the problem
persists. Also, the error being raised does appear to be on the server
side. Still hoping for some help here to keep my project viable and on
track.

Ken.
 
N

Nathaniel Talbott

Can we see your rescue code? I would guess that there's an issue there
that's causing this problem. As to the more general problem of why the
error's being raised in the first place, it would help a lot to debug
it if you could reduce it to a very simple case and post the code here,
along with OS information for where you're running the client and
server.

Thanks,


Nathaniel
Terralien, Inc.

<:((><
 
K

Ken Hilton

Tried the DRB at the link you provide and Ruby for windows 1.8.1-13-rc2 and
the problem persists. I continue to hope someone out there can help me out
so my project can remain viable and on track. Thanks,

Ken.

PS. The error raised by DRb appears to be on the server side and only is
raised when the client process exits, not when the DRb client side service
is stopped.
 
K

Ken Hilton

Hi Nathaniel,

Thanks for posting. The sample code, OS info and output are in the head
item of this new thread. I can send it to you directly if that helps. And
agin THANKS for replying as I'm rather over a barrel at this point :)

-Ken.
 
N

Nathaniel Talbott

Thanks for posting. The sample code, OS info and output are in the
head
item of this new thread. I can send it to you directly if that helps.
And
agin THANKS for replying as I'm rather over a barrel at this point :)

Oops... should've backtracked a bit more :-/

I think the reason you're not able to rescue the exception is because
it is raised in a thread that DRb starts, and thus terminates that
thread when it occurs. It never propagates to the thread in which you
have the rescue.

I'll mull over the more general problem a bit more, as I seem to
remember encountering it on a project I did a few months ago.

HTH,


Nathaniel
Terralien, Inc.

<:((><
 
K

Ken Hilton

Here's the code again, for your convenience. And, when I step through this,
the error in the server occurs when the client process terminates, not when
it stops its local DRb service session.

THANKS,

Ken.


-------------------- drbsvr.rb

# drb server

require 'drb'

class MySvr
def svc(stop)
puts "MySvr::svc called."
return "Service completed."
end
end

$stdout.sync=true;

while true
begin
puts "Starting MySvr..."
DRb.start_service("druby://localhost:9000", MySvr.new());
DRb.thread.join;
puts "MySvr has terminated"
rescue DRb::DRbConnError
puts "Rescued DRbConnectionClosed: #{$!}"
end
end

---------------drbclnt.rb
# drb client
require 'drb'

begin

DRb.start_service(nil,nil);
svr = DRbObject.new(nil, "druby://localhost:9000")
10.times do
puts svr.svc(false);
end
DRb.stop_service;

rescue DRb::DRbConnError
puts "Rescued #{$!}"
end

------------Client output
Debug.rb
Emacs support available.

H:/qbbpo/src/vendornet/etc/
(rdb:1) c
Service completed.
Service completed.
Service completed.
Service completed.
Service completed.
Service completed.
Service completed.
Service completed.
Service completed.
Service completed.
Press any key to continue

------------ Server output & DRb error
(rdb:1) c
Starting MySvr...
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:104: `connection closed'
(DRb::
RbConnError)
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:596:in `start'
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:596:in `run'
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:549:in
`initialize

from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:737:in `new'
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:737:in
`start_serv
ce'
from H:/qbbpo/src/vendornet/etc/drbsvr.rb:17
e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:104:
raise(DRbConnError, '
onnection closed') if sz.nil?
(rdb:3)
 
K

Ken Hilton

Joel VanderWerf said:
I realize this is not much help to you, but it works fine on linux, with
either 1.8.1 or 1.9.0.

Greetings,

Thanks to those of you who helped me out. It appears (today) that
I've resolved this problem, but I'm still not completely satisfied.
It turns out the macros and batch files I use during development
always launch ruby.exe in debug mode (-rdebug). When I happened to
test the code I wrote to isolate this problem NOT in debug mode, the
problem does not manifest (as I suppose others who ran the program
experienced.) So, my new question is this: do any of you see this
problem when you run my test app in debug mode and if so, what do you
make of it? Is it perhaps a feature and not a debug (a diagnostic
perhaps?)

Cheers,

Ken.
 
D

daz

Ken said:
Greetings,

Thanks to those of you who helped me out. It appears (today) that
I've resolved this problem, but I'm still not completely satisfied.
It turns out the macros and batch files I use during development
always launch ruby.exe in debug mode (-rdebug).

Knowledge of that could make a considerable difference ;-)
[snip] So, my new question is this: do any of you see this
problem when you run my test app in debug mode [...]

Y e s ( ruby 1.9.0 (2004-04-27) [i586-bccwin32], Win98se )
[...] and if so, what do you make of it?

As I'm a lower life-form, not a lot.

require 'debug' # added to server script; run ...
# ... give 'c' at debug prompt; run client

# (changed loop to 3.times)
---------------------------
D:/ruby/DfB/clr/DRb/server2_hilton.rb:12:
(rdb:1) c
Starting MySvr...
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:558: `connection closed' (DRb::DRbConnError)
from D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1321:in `start'
from D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1321:in `run'
from D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1246:in `initialize'
from D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1502:in `new'
from D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1502:in `start_service'

from D:/ruby/DfB/clr/DRb/server2_hilton.rb:29
D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:558: raise(DRbConnError, 'connection closed') if sz.nil?
(rdb:3) w
--> #1 D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:558:in `load'
#2 D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:591:in `recv_request'
#3 D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:855:in `recv_request'
#4 D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1406:in `init_with_client'
#5 D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1418:in `setup_message'
#6 D:/RUBY/SRC_CVSINST/lib/ruby/1.9/drb/drb.rb:1388:in `perform'
(rdb:3)
---------------------------


A note to higher life-forms:
I added a set_trace_func to drb.rb (outputting to a file) in order
to provide some useful log data to pass on. Of course, whenever
one carefully sets a trap, the bug decides to stay away :((

In drb.rb, replaced equal number of doc lines with code below to preserve
reference lines. Gives full trace - but no DRb::DRbConnError
(with require 'debug' still in the server script).

#--------------
$tf = File.open('drbsrv2_trace.txt', 'w')
END { $tf.close }
#
stf1 = lambda { | ev, fi, li, ty, bi, cl |
$tf.printf("\n %20s :%4d: %25s %15s %8s ... ", File.basename(fi), li, ty, cl, ev)
}
stf2 = lambda { | ev, fi, li, ty, bi, cl | #?# set_trace_func(stf2) # dbg (inside thread)
$tf.printf("\n<THR> %20s :%4d: %25s %15s %8s ... ", File.basename(fi), li, ty, cl, ev)
}
#set_trace_func(stf1) # dbg (main thread) # <---- [Note:1]
#--------------

[Note:1] uncomment the line to "fix" the require 'debug' problem.


Then disabled the trace and tried sprinkling "sleep 0.2" around to slow
things down a different way -- no difference.


daz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top