Reputation: 213
i'm trying to open an exec and an sftp channel simultaneously but when i open the sftp channel gives me an error, the code (simplified) is this:
JSch connection = new JSch();
Session session = connection.getSession(user, ip, port);
session.setPassword(password);
session.connect(15000);
ChannelExec channel = (ChannelExec) session.openChannel("exec");
//exec commands whit channel
Channel ch;
ch = ssh.session.openChannel("sftp");
ch.connect();//-------ERROR!
ChannelSftp sftp = (ChannelSftp)ch;
the error is: "com.jcraft.jsch.JSchException: channel is not opened."
Upvotes: 2
Views: 6153
Reputation: 19918
Try to increase the timeout:
ch.connect(60 * 1000); // A minute wait for connection.
Upvotes: 2