Net/SSH port forwarding doesn't work. -------------------------------------
Key: JRUBY-5868 URL: http://jira.codehaus.org/browse/JRUBY-5868 Project: JRuby Issue Type: Bug Components: Standard Library Affects Versions: JRuby 1.6.2 Environment: MacOS X 10.6.7, JRuby 1.6.2, Java build 1.6.0_24-b07-334 Reporter: Kevin Menard Assignee: Thomas E Enebo When attempting to port forward a local port so that it's available to a remote machine, the connection seems to establish fine but I'm unable to access any content from the remote machine on the forwarded port. A connection is established, but trying to fetch content on it always times out. I do not have this issue when running with either REE or Ruby 1.9.2. Below is as simple a code example as I was able to distill it down. It's still a bit heavy. In the example, I show forwarding port 3000 on the localhost to port 12345 on example.com. {code} require 'rubygems' require 'net/ssh' require 'net/ssh/gateway' # http://groups.google.com/group/capistrano/browse_thread/thread/455c0c8a6faa9cc8?pli=1 class Net::SSH::Gateway # Opens a SSH tunnel from a port on a remote host to a given host and port # on the local side # (equivalent to openssh -R parameter) def open_remote(port, host, remote_port, remote_host = "127.0.0.1") ensure_open! @session_mutex.synchronize do @session.forward.remote(port, host, remote_port, remote_host) end if block_given? begin yield [remote_port, remote_host] ensure close_remote(remote_port, remote_host) end else return [remote_port, remote_host] end rescue Errno::EADDRINUSE retry end # Cancels port-forwarding over an open port that was previously opened via # #open_remote. def close_remote(port, host = "127.0.0.1") ensure_open! @session_mutex.synchronize do @session.forward.cancel_remote(port, host) end end end gateway = Net::SSH::Gateway.new('example.com', 'some_user') gateway.open_remote(3000, 'localhost', 12345) do |rp, rh| puts "You're now connected and reflecting ports" begin sleep 1 while true rescue Interrupt puts "Shutting down" end end {code} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email