Hi all.
I have a problem with Jsch for remote port forwarding. I set up a
connection without problems. Local port forwarding works as well.
But when using remote port forwarding:
session.setPortForwardingR(778, "localhost", 3306);
I get an exception:
Caused by: com.jcraft.jsch.JSchException: remote port forwarding failed
for listen port 778
at com.jcraft.jsch.Session.setPortForwarding(Session.java:1658)
at com.jcraft.jsch.Session.setPortForwardingR(Session.java:1597)
at com.jcraft.jsch.Session.setPortForwardingR(Session.java:1587)
at
com.camunda.bpp.gatekeeper.agents.SshAgent.start(SshAgent.java:47)
Anybody any idea?
When I use remote port forwarding via Putty or another SSH client, it
works fine, so it must be a problem with Jsch. Any help would be
appreciated!
By the way, the Exception is thrown because of a reply=0 (whatever that
means?):
private void setPortForwarding(String bind_address, int rport) throws
JSchException{
synchronized(grr){
Buffer buf=new Buffer(100); // ??
Packet packet=new Packet(buf);
String address_to_bind=ChannelForwardedTCPIP.normalize(bind_address);
try{
// byte SSH_MSG_GLOBAL_REQUEST 80
// string "tcpip-forward"
// boolean want_reply
// string address_to_bind
// uint32 port number to bind
packet.reset();
buf.putByte((byte) SSH_MSG_GLOBAL_REQUEST);
buf.putString("tcpip-forward".getBytes());
// buf.putByte((byte)0);
buf.putByte((byte)1);
buf.putString(address_to_bind.getBytes());
buf.putInt(rport);
write(packet);
}
catch(Exception e){
if(e instanceof Throwable)
throw new JSchException(e.toString(), (Throwable)e);
throw new JSchException(e.toString());
}
grr.setThread(Thread.currentThread());
try{ Thread.sleep(10000);}
catch(Exception e){
}
int reply=grr.getReply();
grr.setThread(null);
if(reply==0){
throw new JSchException("remote port forwarding failed for listen
port "+rport);
}
}
}
Cheers
Bernd
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users