preetam patil
preetam patil

Reputation: 73

How to release assigned local port in JSch tunneling?

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);

Upvotes: 1

Views: 658

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202534

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.

Upvotes: 1

Related Questions