1

How to release assigned local port in JSch tunneling automatically after specified time or when the port is inactive?

I used the following function to achieve port forwarding:

session.setPortForwardingL("my.ip",9901,remote_host,1001,ssf,1000);
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

You have to implement the timeout yourself and call the Session.delPortForwardingL.


The connectTimeout that you are setting in Session.setPortForwardingL call is only passed to Channel.connect(connectTimeout) and limits how long will the code wait for the channel to open. The name (connectTimeout) says it after all. It has no effect whatsoever after the channel/forwarding is opened.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992