DRb Connection Closed Error?!?!?!?

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:instart’
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:ininitialize’

    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)

Ken Hilton wrote:

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.

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)

“Ken Hilton” kenosis@comcast.net wrote in message
news:iStmc.42859$I%1.2775243@attbi_s51…

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)

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

Ken.

“Joel VanderWerf” vjoel@PATH.Berkeley.EDU wrote in message
news:409A7E7A.9090409@path.berkeley.edu…

Ken Hilton wrote:

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.

I see there is a Metro-Detroit Ruby’s User Group which was posted by Mike
Sassak in Feb. of 2002. I haven’t seen Mike Sassak post in quite a while, is
he still around? I’m in the Grand Rapids area and I am looking for other
West Michigan Ruby folks. Any out there?

Feel free to email me off list,

Zach Dennis
Market Technologies Inc.

Joel VanderWerf vjoel@PATH.Berkeley.EDU wrote in message news:409A7E7A.9090409@path.berkeley.edu

Ken Hilton wrote:

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.

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.

Ken Hilton wrote:

Joel VanderWerf wrote:

Ken Hilton wrote:

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.

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

Ken.

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

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

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/cvsweb.cgi/~checkout~/ruby/lib/drb/drb.rb?rev=1.11.2.5;content-type=text%2Fplain

Cheers,

daz

Ken Hilton wrote:

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

[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 %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

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.

“daz” dooby@d10.karoo.co.uk wrote in message
news:HsucnTcqg-of9wbdSa8jmw@karoo.co.uk

Ken Hilton wrote:

Joel VanderWerf wrote:

Ken Hilton wrote:

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.

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

Ken.

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

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

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/cvsweb.cgi/~checkout~/ruby/lib/drb/drb.rb?rev=1.11.2.5;content-type=text%2Fplain

···

Cheers,

daz

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.

“daz” dooby@d10.karoo.co.uk wrote in message
news:HsucnTcqg-of9wbdSa8jmw@karoo.co.uk

Ken Hilton wrote:

Joel VanderWerf wrote:

Ken Hilton wrote:

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.

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

Ken.

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

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

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/cvsweb.cgi/~checkout~/ruby/lib/drb/drb.rb?rev=1.11.2.5;content-type=text%2Fplain

···

Cheers,

daz

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.

<:((><

···

On May 7, 2004, at 11:18, Ken Hilton wrote:

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

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

-Ken.

“Nathaniel Talbott” nathaniel@talbott.ws wrote in message
news:464D2E7C-A043-11D8-86DE-000A95CD7A8E@talbott.ws…

···

On May 7, 2004, at 11:18, Ken Hilton wrote:

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

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.

<:((><

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.

<:((><

···

On May 7, 2004, at 14:18, Ken Hilton wrote:

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