karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-5473) Karaf SSH session timing out
Date Sun, 11 Feb 2018 18:09:00 GMT

    [ https://issues.apache.org/jira/browse/KARAF-5473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16360042#comment-16360042
] 

ASF GitHub Bot commented on KARAF-5473:
---------------------------------------

jbonofre closed pull request #440: [KARAF-5473] Add heartbeat by default in Karaf ssh client
URL: https://github.com/apache/karaf/pull/440
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml
index a3bea5a18f..6f7392a9fc 100644
--- a/assemblies/features/standard/src/main/feature/feature.xml
+++ b/assemblies/features/standard/src/main/feature/feature.xml
@@ -289,7 +289,6 @@
             #
             hostKeyFormat = simple
 
-
             #
             # Self defined key size in 1024, 2048, 3072, or 4096
             # If not set, this defaults to 2048.
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 a493332b9c..987516cbcd 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -42,6 +42,7 @@
 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;
@@ -51,6 +52,7 @@
 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;
@@ -95,8 +97,7 @@ public static void main(String[] args) throws Exception {
             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) {
@@ -160,7 +161,13 @@ else if (console != null) {
             }
             
             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();
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index dc4fab7613..075c10a27f 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -435,7 +435,9 @@ private CharSequence readCommand(AtomicBoolean reading) throws UserInterruptExce
             if (pl instanceof ParsedLineImpl) {
                 command = ((ParsedLineImpl) pl).program();
             } else {
-                command = pl.line();
+                if (pl != null) {
+                    command = pl.line();
+                }
             }
         } catch (EndOfFileException e) {
             command = null;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Karaf SSH session timing out
> ----------------------------
>
>                 Key: KARAF-5473
>                 URL: https://issues.apache.org/jira/browse/KARAF-5473
>             Project: Karaf
>          Issue Type: Bug
>    Affects Versions: 4.1.2, 4.2.0.M1
>         Environment: Tried on two different machines, both running Debian 8.9
>            Reporter: Daniel Malmgren
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>             Fix For: 4.2.0, 4.1.5
>
>
> SSH sessions into Karaf are aborted after about ten minutes of inactivity. The following
message is written to the log:
> 14:35:26.042 WARN [sshd-SshServer[616ddc]-nio2-thread-2] exceptionCaught(ServerSessionImpl[karaf@/127.0.0.1:40676])[state=Opened]
InterruptedByTimeoutException: null
> The problem started some weeks ago with the Karaf version shipped with openHAB, it's
currently on 4.1.2. I've also tried a plain Karaf container though (version 4.2.0.M1) and
get the exact same problem there. This has been discussed in the openHAB forum here: [https://community.openhab.org/t/timeout-in-karaf-console/35443]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message