Repository: cloudslang/cs-actions
Issue: SSH: session is down

when executing "big" flow, we get the following error message sporadically:

```
11/08/15 08:42:07 [DEBUG] Event received: EVENT_ACTION_END Data is: {DESCRIPTION=Action performed, PATH=0.11.2.1.0.0.1, RETURN_VALUES={returnCode=-1, returnResult=com.jcraft.jsch.JSchException: session is down, exception=java.lang.RuntimeException: com.jcraft.jsch.JSchException: session is down
    at io.cloudslang.content.ssh.services.impl.SSHServiceImpl.runShellCommand(SSHServiceImpl.java:150)
    at io.cloudslang.content.ssh.services.actions.ScoreSSHShellCommand.runSSHCommand(ScoreSSHShellCommand.java:78)
    at io.cloudslang.content.ssh.services.actions.ScoreSSHShellCommand.execute(ScoreSSHShellCommand.java:51)
    at io.cloudslang.content.ssh.actions.SSHShellCommandAction.runSshShellCommand(SSHShellCommandAction.java:103)
    at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at io.cloudslang.lang.runtime.steps.ActionSteps.invokeActionMethod(ActionSteps.java:137)
    at io.cloudslang.lang.runtime.steps.ActionSteps.runJavaAction(ActionSteps.java:112)
    at io.cloudslang.lang.runtime.steps.ActionSteps.doAction(ActionSteps.java:77)
    at sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at io.cloudslang.worker.execution.reflection.ReflectionAdapterImpl.executeControlAction(ReflectionAdapterImpl.java:62)
    at io.cloudslang.worker.execution.services.ExecutionServiceImpl.executeStep(ExecutionServiceImpl.java:326)
    at io.cloudslang.worker.execution.services.ExecutionServiceImpl.execute(ExecutionServiceImpl.java:80)
    at io.cloudslang.worker.management.services.SimpleExecutionRunnable.executeRegularStep(SimpleExecutionRunnable.java:159)
    at io.cloudslang.worker.management.services.SimpleExecutionRunnable.run(SimpleExecutionRunnable.java:119)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at io.cloudslang.worker.management.services.WorkerThreadFactory$1.run(WorkerThreadFactory.java:33)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.jcraft.jsch.JSchException: session is down
    at com.jcraft.jsch.Channel.sendChannelOpen(Channel.java:667)
    at com.jcraft.jsch.Channel.connect(Channel.java:151)
    at io.cloudslang.content.ssh.services.impl.SSHServiceImpl.runShellCommand(SSHServiceImpl.java:129)
    ... 23 more
}, STEP_NAME=null, STEP_TYPE=ACTION, TIMESTAMP=Tue Aug 11 08:42:07 UTC 2015, EXECUTION_ID=101600025, TYPE=EVENT_ACTION_END}
```

now that we run our tests automatically, this often causes build failure,
expected behavior would be to reestablish the session is such case

issue in cloud-slang-content: CloudSlang/cloud-slang-content#318

https://circle-artifacts.com/gh/CloudSlang/cloud-slang-content/1381/artifacts/1/home/ubuntu/cloud-slang-content/builder.log


Changed files:
score-ssh/src/main/java/io/cloudslang/content/ssh/services/impl/SSHServiceImpl.java

diff --git a/score-ssh/src/main/java/io/cloudslang/content/ssh/services/impl/SSHServiceImpl.java b/score-ssh/src/main/java/io/cloudslang/content/ssh/services/impl/SSHServiceImpl.java
index ff738803e..ae2e39d13 100644
--- a/score-ssh/src/main/java/io/cloudslang/content/ssh/services/impl/SSHServiceImpl.java
+++ b/score-ssh/src/main/java/io/cloudslang/content/ssh/services/impl/SSHServiceImpl.java
@@ -114,6 +114,9 @@ public class SSHServiceImpl implements SSHService {
     @Override
     public CommandResult runShellCommand(String command, String characterSet, boolean usePseudoTerminal, int connectTimeout, int commandTimeout, boolean agentForwarding) {
         try {
+            if (!isConnected()) {
+                session.connect(connectTimeout);
+            }
             // create shell channel
             Channel channel = session.openChannel(SHELL_CHANNEL);
             ((ChannelShell) channel).setPty(usePseudoTerminal);