Hi, guys.
We are using JSCH 0.1.41 in our intranet to monitor 500+ hosts with various
kinds of OS/SSH servers, out program issues at least 1000 SSH commands in
one minutes. JSCH works well.
But we had to resolve some bugs before we can make it work under this high
work load. We started from 0.1.39, it already had these problems. 140, 141
didn't fix them.
1 NPE on some hosts
About 1/5 of our host got NPE somewhere in Channel from time to time. It
seems that channel.io is set to null by some thread in Request.java
We had to save channel.io to make sure it always valid.
2 infinite loop in Session.java
Under very rare condition, Session.java can be stuck in a infinite loop.
I believe it is caused by a possible bug in Session.java.
We had to copy timeout checking code from other JSCH class.
3 While Channel throw an Exception, it doesn't include cause, this makes it
harder to track problems in our case.
Here is my patch, I hope it can be useful to someone and would you mind
apply the patch if it does make sense?
By the way, JSCH still could not connect to some of our Apple servers, we
didn't resolve this issue yet.
Index: com/jcraft/jsch/Channel.java
===================================================================
--- com/jcraft/jsch/Channel.java (revision 1977)
+++ com/jcraft/jsch/Channel.java (working copy)
@@ -203,7 +203,7 @@
connected=false;
if(e instanceof JSchException)
throw (JSchException)e;
- throw new JSchException(e.toString());
+ throw new JSchException(e.toString(), e);
}
}
Index: com/jcraft/jsch/Request.java
===================================================================
--- com/jcraft/jsch/Request.java (revision 1979)
+++ com/jcraft/jsch/Request.java (working copy)
@@ -47,6 +47,8 @@
channel.reply=-1;
}
session.write(packet);
+ IO iorequest2 = channel.io; // in some case, IO is set to null
+
if(reply){
long start=System.currentTimeMillis();
long timeout=channel.connectTimeout;
@@ -54,6 +56,8 @@
try{Thread.sleep(10);}
catch(Exception ee){
}
+ channel.io = iorequest2; // in some case, IO is set to null
+
if(timeout>0L &&
(System.currentTimeMillis()-start)>timeout){
channel.reply=0;
Index: com/jcraft/jsch/Session.java
===================================================================
--- com/jcraft/jsch/Session.java (revision 1977)
+++ com/jcraft/jsch/Session.java (working copy)
@@ -1142,7 +1142,15 @@
public void write(Packet packet) throws Exception{
// System.err.println("in_kex="+in_kex+" "+(packet.buffer.getCommand
()));
- while(in_kex){
+ long timeout = this.getTimeout();
+ // in_kex can be always true in some case
+ long start = System.currentTimeMillis();
+ while(in_kex){
+ if (
+ timeout>0L &&
+ (System.currentTimeMillis()-start)>timeout) {
+ throw new JSchException("timeout writting to packet");
+ }
byte command=packet.buffer.getCommand();
//System.err.println("command: "+command);
if(command==SSH_MSG_KEXINIT ||
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users