MendixCap / MX--SFTP-Module

Mendix SFTP Module
3 stars 4 forks source link

Session Is Down #3

Open stephanbruijnis opened 7 years ago

stephanbruijnis commented 7 years ago

Hi

I get this issue a few minutes after using the SFTP configuration for the first time, also see this topic: https://forum.mendixcloud.com/link/questions/87263

Tested in mx6.8.1.

com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.jcraft.jsch.JSchException: session is down
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:398)

Caused by: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.jcraft.jsch.JSchException: session is down
    at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:178)

Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: com.jcraft.jsch.JSchException: session is down
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:40)

Caused by: com.jcraft.jsch.JSchException: session is down
    at com.jcraft.jsch.Session.openChannel(Session.java:853)
    at sftpconnection.helpers.HandleFileSftp.createSFTPChannel(HandleFileSftp.java:55)
    at sftpconnection.helpers.HandleFileSftp.getFileDocumentFromSFTP(HandleFileSftp.java:173)
    at sftpconnection.actions.GetFileDocumentFromSFTPLocation.executeAction(GetFileDocumentFromSFTPLocation.java:50)
    at sftpconnection.actions.GetFileDocumentFromSFTPLocation.executeAction(GetFileDocumentFromSFTPLocation.java:22)
    at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
    at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260)
    at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248)
    at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:174)
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:390)
    at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:52)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
    at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
    at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260)
    at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248)
    at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:174)
    at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:472)
    at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:43)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
    at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
    at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260)
    at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248)
    at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:174)
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:390)
    at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:144)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:314)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:304)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:304)
    at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:144)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:146)
    at scala.util.Try$.apply(Try.scala:192)
    at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:140)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
    at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:136)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
    at akka.actor.ActorCell.invoke(ActorCell.scala:487)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
    at akka.dispatch.Mailbox.run(Mailbox.scala:220)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
dkho87 commented 7 years ago

I've encountered the error in Mx 7.5.1 and 7.6.0 as well.

ErikPoels commented 6 years ago

The problem is in HandleFileSftp.java. In the element createSFTPChannel the following code retrieves previous sessions:

if(userSession.containsKey(session.getUserName())){ session = userSession.get(session.getUserName()); } else{ session = ConnectSession(session); }

The variable userSession is only set in the element setKnownHosts and in the element createSession when StrictHostkeyChecking is false. On the first try userSession variable is empty and will be filled with the current session. On the next tries it will find the old session (which is somehow not closed yet, even with the .disconnect() ) and use that session. This will eventually expire and when this happens, the message "sessioen is down" will appear.

Removing the line of code makes sure it will not happen again. I didn't check what happens when using StrictHostkeyChecking is true.