1

I am experiencing a really weird behaviour with Ruby DRb or maybe the problem is dbm. I am using the dbm database with a server, and a client that makes the requests via DRb.

Here's the method with the problem (the database connection is ok) and it is in the server:

def get id
    obj = nil
    db = DBM.open @name
    obj = db[id.to_s]
    db.close
    return obj
end

This line obj = db[id.to_s] returns the error connection closed (DRb::DRbConnError) in the client side.

The thing is if I do this obj = db['1'] it works just fine ('1' is a key in the dbm). Why does this happen? What is wrong with id? Here's the call in the client side:

DRb.start_service
r = DRbObject.new_with_uri(SERVER_URI)
puts r.get '1'

Why am I getting this error? The same thing happens with this method:

def delete id
    db = DBM.open @name
    db.delete id
    db.close
end
4

2 回答 2

0

/lib/drb/drb.rb中,似乎在sz.nil?和时引发了连接关闭错误str.nil

raise(DRbConnError, 'connection closed') if sz.nil?

raise(DRbConnError, 'connection closed') if str.nil?

返回什么obj = db[id.to_s]

于 2014-12-04T15:14:44.200 回答
0

尝试修补您的 ruby​​,以便为您提供有关关系的服务器端错误的更多详细信息。

请参阅:https ://github.com/ruby/ruby/pull/1260 。

在我的情况下,声明 a 是一个问题,safe_level然后我调用的一些代码最终违反了安全性(即发出“危险调用”)。

于 2016-02-21T00:20:58.383 回答