Is there any possibility to reuse SshClient instance?
- Dominant language
- Java
- Stars
- 2.7k
- Forks
- 620
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 11
Description
I create an sshClient instance and want to reuse in next request.
But when I close the shell or session it open, the sshClient will be close too.
And when I didn't close the shell or session, the next request to startSession will hang there.
codes below:
init method:
```java
public static void init() throws IOException {
DefaultConfig config = new DefaultConfig();
sshClient = new SSHClient(config);
sshClient.loadKnownHosts();
sshClient.connect(host, port);
sshClient.authPassword(usernmae, password.toCharArray());
}
```
close the session
```java
//next request , sshClient.isConnected will always be false.
if(!sshClient.isConnected()) {
init();
}
Session session = sshClient.startSession();
Session.Shell shell = session.startShell();
//do biz
IOUtils.closeQuietly(outputStream);
shell.close();
session.close();
```
and if I didn't close the shell
```java
if(!sshClient.isConnected()) {
init();
}
// next request here, will hang up
Session session = sshClient.startSession();
Session.Shell shell = session.startShell();
//do biz
IOUtils.closeQuietly(outputStream);
//do not close session
```
Thanks for have a read.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.