java - Ganymed-ssh - how to set timeout to close session when execCommand takes more time -


i'm using ganymed-ssh pull log details remotely. below code. data returned stdout huge , takes more time return. want close session if stdout did not return in 1 minute. how set timeout session close automatically stdout took more 1 minute ?

connection conn = new connection(hostname); conn.connect(); boolean isauthenticated = conn.authenticatewithpassword(username, password); if (isauthenticated == false)    throw new ioexception("authentication failed."); session session = conn.opensession(); session.execcommand("grep traceid trace.log"); inputstream stdout = new streamgobbler(session.getstdout()); bufferedreader br = new bufferedreader(new inputstreamreader(stdout)); while (true)      {          string line = br.readline();          if (line == null)               break;          system.out.println(line);       } system.out.println("exitcode: " + session.getexitstatus()); session.close(); conn.close(); 

you can use waitforcondition method or waituntildataavailable method of session class. both needs timeout parameter.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -