khris
khris

Reputation: 4999

com.jcraft.jsch.JSchException: session is down

I use follawing code to execute commands on Linux via Windows:

  JSch jsch=new JSch();  
    Session session=jsch.getSession(user, host, port);
    session.setConfig(props);
    session.setPassword(pwd);
    session.connect();
    ChannelShell channel = (ChannelShell)session.openChannel("shell");
    boolean ch = channel.isConnected();
    channel.sendSignal("ls");
    channel.connect();
    boolean ch1 = channel.isConnected();

But it fails on line channel.connect();:

com.jcraft.jsch.JSchException: session is down
at com.jcraft.jsch.Channel.connect(Channel.java:172)
at com.jcraft.jsch.Channel.connect(Channel.java:132)

How fix such error?

Upvotes: 4

Views: 11948

Answers (1)

Shishir Dwivedi
Shishir Dwivedi

Reputation: 43

Try to use some polling where you can check active status of session. for reference you can check this link

Upvotes: 1

Related Questions