Hi,
 
I'm performing a scp copy of a directory from a Windows machine to an AIX server through JSch.
I started by using the ScpTo.java example for every file in the directory but the transfer was quite slow due to the multiple session connections needed.
 
My idea was to use a single JSch session to complete the full copy of the files.
I implemented a static Session which is instanciated and retrieved through a getSession() method:
private static Session session;
 
public static Session getSession(String user, String host, String mdp) {
if (session==null || !session.isConnected())
{
try {
JSch jsch = new JSch();
session = jsch.getSession(user, host, 22);
MyUserInfo ui = new MyUserInfo();
ui.setPassword(mdp);
session.setUserInfo(ui);
session.setDaemonThread(true);
session.connect();
} catch (JSchException e) {
e.printStackTrace();
}
}
return session;
}
Then, in the main function executing the copy, the channels are created from this static session:
session
= getSession(user, host, mdp);
String command = "scp -p -t " + rfile+"/"+lfile;
Channel chan = session.openChannel("exec");
However, i get sometimes the error message "session is down" when performing a copy.

session is down

at com.jcraft.jsch.Channel.connect(

Channel.java:186)
at com.jcraft.jsch.Channel.connect(
Channel.java:144)
...
It seems to appear at random with this configuration. It happens a bit more frequently if a timeout value is set for the session. And it happens almost every time if a timeout value is set for the channels.
 
Do you know the reason behind this behaviour?
Thanks,
 
Regards,
Christophe Canonville