I've been doing some testing with Ruby drb. I have the following code (just the example code found on the ruby docs)
SERVER:
require 'drb/drb'
URI="druby://:9000"
class TimeServer
def get_current_time
return Time.now
end
end
FRONT_OBJECT=TimeServer.new; $SAFE = 1
DRb.start_service(URI, FRONT_OBJECT)
DRb.thread.join
CLIENT:
require 'drb/drb'
SERVER_URI="druby://private-ip:9000"
DRb.start_service
timeserver = DRbObject.new_with_uri(SERVER_URI)
puts timeserver.get_current_time
This works if we're both connected to the same router (and share the same private-ip x.x.x.151 and x.x.x.155 for instance).
But, when we're testing on machines miles apart and changing the server URI to SERVER_URI="druby://public-ip-of-server:9000"
on the client side, we're getting a connection timeout.
Does anyone know the solution? Port forwarding on the router is not an option.
I think your problem is that your dealing with a State-full Packet inspection firewall(spi). most firewall will not allow network connections from the outside that were not established from the inside first.
the way skype get around this is to have the client establish the connection to a server on the internet then connect back and have the client connect to additional port required to complete the contention. In any case one side needs to accept connections.
1) If you have access to a web server you could implement your service as a restfull web service.
2) drb does not provide encryption or security so you might want to think about wrapping it in ssl or ssh.