I haven’t done any DRb stuff in awhile, but I used to connect to a DRb
server from
a rails controller. I’ve never tried it in rails 3 and am wondering if
Rails 3 is stricter about something like this or why it hasn’t worked
thus far.
My server/client code and error are shown below:
SERVER:
require ‘drb’
class ParserSvc
def initialize
end
def check
return ‘ok’
end
end
svc = ParserSvc.new
DRb.start_service ‘druby://:9000’, svc
puts “Server running at #{DRb.uri}”
trap(“INT”) { DRb.stop_service }
DRb.thread.join
Client code in application controller:
require ‘drb’
class ApplicationController < ActionController::Base
protect_from_forgery
def parser_svc
# svc = nil
svc = DRbObject.new nil, ‘druby://:9000’
svc
end
end
main controller:
def pcheck
svc = parser_svc
res = svc.check
render :text => res
end
when called and server is running get this error:
DRb::DRbConnError (druby://:9000 - #<Errno::EADDRNOTAVAIL: The
requested address
is not valid in its context. - connect(2)>):
app/controllers/main_controller.rb:15:in `pcheck’