Hi, This is a report of test. > I'll try your suggestion and report the result in a few days. > First, I'll set 2000 for the argument of Session#setServerAliveInterval(int > milliseconds).
(1) Result Session#setServerAliveInterval(int milliseconds) didn't seem to make good change in my trouble. (2) Test detail I rebuilt test program, which can easily occur the trouble. It ocuurs in 1 hour run by below source with jsch-1.0.42. The test program checks the time to execute "ls -la". Normally it ends in 80ms, but sometimes it takes more than 3000ms. This trouble occurs in a hour, and Session#setServerAliveInterval() doesn't affected this trouble. (3) Test complete source -------------------------------------------- import com.jcraft.jsch.*; import java.awt.*; import javax.swing.*; import java.io.*; import java.sql.*; public class Exec{ public static void main(String[] arg) throws Exception{ int sessionNum = 100; Session[] sessions = new Session[ sessionNum ]; try{ JSch jsch=new JSch(); String host="****"; String user="****"; String passwd = "****"; for( int i=0; i<sessions.length; i++ ){ Session thisSession=jsch.getSession(user, host, 22); thisSession.setPassword( passwd ); sessions[i] = thisSession; java.util.Hashtable config = new java.util.Hashtable(); config.put( "cipher.s2c", "aes128-cbc,3des-cbc,blowfish-cbc"); config.put( "cipher.c2s", "aes128-cbc,3des-cbc,blowfish-cbc"); config.put( "StrictHostKeyChecking", "no"); thisSession.setConfig( config ); thisSession.setTimeout( 2000 ); // TCP/IP check setting thisSession.setServerAliveInterval( 2000 ); // connect thisSession.connect(); } long average = 0; int loop = 0; boolean canContinue = true; while( canContinue ){ int idx = loop % sessionNum; Session thisSession = sessions[ idx ]; Channel channel = null; channel=thisSession.openChannel("exec"); ((ChannelExec)channel).setCommand( "ls -la" ); ( (ChannelExec)channel ).setPty( true ); ByteArrayOutputStream baos = new ByteArrayOutputStream(); channel.setOutputStream( baos ); InputStream in=channel.getInputStream(); long start = System.currentTimeMillis(); channel.connect(); byte[] tmp=new byte[1024]; while(true){ long end = System.currentTimeMillis(); if(channel.isClosed()){ average += ( end - start ); Timestamp ts = new Timestamp( end ); if( idx==0 ){ System.out.print( "\n[" + idx + "] " + ts.toString() ); } else if( idx == (sessionNum-1) ){ System.out.print( ", average=" + (average/sessionNum) + "ms" ); average = 0; } else if( ( idx % 10 ) == 0 ) { System.out.print( "." ); } break; } try{Thread.sleep( 10 );}catch(Exception ee){} if( ( end - start ) > 30000 ){ System.out.println( (end-start) + "ms, more than 30sec, break"); canContinue = false; break; } } channel.disconnect(); // loop counter loop++; } } catch(Exception e){ e.printStackTrace(); }finally{ for( int i=0; i<sessionNum; i++ ){ sessions[i].disconnect(); } } } } -------------------------------------------- (4) The stdout at problem [0] 2010-01-12 16:46:56.109........., average=79ms [0] 2010-01-12 16:47:04.038........., average=78ms [0] 2010-01-12 16:47:11.926........., average=76ms .... [0] 2010-01-12 17:37:42.072........., average=74ms [0] 2010-01-12 17:37:49.588....30002ms, more than 30sec, break Sincerely, ---------------------------------- Yukimasa Matsuda Quatre-i Science Co., Ltd. e-mail: mats...@i4s.co.jp http://www.i4s.co.jp ---------------------------------- ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ JSch-users mailing list JSch-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jsch-users