You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2018/02/11 19:19:25 UTC
[karaf] branch karaf-4.1.x updated: [KARAF-5473] Add heartbeat by
default in Karaf ssh client
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.1.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.1.x by this push:
new 660cb59 [KARAF-5473] Add heartbeat by default in Karaf ssh client
660cb59 is described below
commit 660cb59a74c87b765b4a5359296b92af19497a90
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Tue Feb 6 15:26:29 2018 +0100
[KARAF-5473] Add heartbeat by default in Karaf ssh client
---
client/src/main/java/org/apache/karaf/client/Main.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/client/src/main/java/org/apache/karaf/client/Main.java b/client/src/main/java/org/apache/karaf/client/Main.java
index a179731..bf3092c 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -44,6 +44,7 @@ import org.apache.sshd.agent.SshAgent;
import org.apache.sshd.agent.local.AgentImpl;
import org.apache.sshd.agent.local.LocalAgentFactory;
import org.apache.sshd.client.ClientBuilder;
+import org.apache.sshd.client.ClientFactoryManager;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.auth.keyboard.UserInteraction;
import org.apache.sshd.client.channel.ChannelExec;
@@ -54,6 +55,7 @@ import org.apache.sshd.client.channel.PtyCapableChannelSession;
import org.apache.sshd.client.future.ConnectFuture;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.RuntimeSshException;
import org.apache.sshd.common.channel.PtyMode;
import org.apache.sshd.common.config.keys.FilePasswordProvider;
@@ -99,8 +101,7 @@ public class Main {
config.setCommand(sb.toString());
}
- try (SshClient client = ClientBuilder.builder().build())
- {
+ try (SshClient client = ClientBuilder.builder().build()) {
FilePasswordProvider passwordProvider = null;
final Console console = System.console();
if (console != null) {
@@ -164,7 +165,13 @@ public class Main {
console.printf("Logging in as %s\n", config.getUser());
}
setupAgent(config.getUser(), config.getKeyFile(), client, passwordProvider);
- client.getProperties().put(FactoryManager.IDLE_TIMEOUT, String.valueOf(config.getIdleTimeout()));
+
+ // define hearbeat (for the keep alive) and timeouts
+ // TODO this should be dealt by Apache SSH client directly using .ssh/config
+ client.getProperties().put(ClientFactoryManager.HEARTBEAT_INTERVAL, "60000");
+ client.getProperties().put(ClientFactoryManager.IDLE_TIMEOUT, String.valueOf(config.getIdleTimeout()));
+ client.getProperties().put(ClientFactoryManager.NIO2_READ_TIMEOUT, String.valueOf(config.getIdleTimeout()));
+
// TODO: remove the line below when SSHD-732 is fixed
client.setKeyPairProvider(new FileKeyPairProvider());
client.start();
--
To stop receiving notification emails like this one, please contact
jbonofre@apache.org.