Hi Ram
Even we faced this issue where in when we tried downloading huge file
from a remote server ( only few servers) jsch channel hangs infinitely.
After debugging we found that this happens only on those servers where
the the SSH version shown was <= - SSH-1.99-OpenSSH_3.5p1. As per our
understanding the version of SSH is quite old probably more than 4
years. Please check the server SSH version where you are facing this
issue and also try to execute the same scenario on a server with latest
SSH version installed.
Regards
Tiru Kumar K Sheth
Alcatel-Lucent
Lead Engineer
OMC-H
BPL Software Centre,11th KM,
Bannerghatta Road,Arakere,
Bangalore 560076
[EMAIL PROTECTED]
Phone : +91-80- 6622 2023 Xtn: 2023
Fax : +91-80- 6622 2500
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ram
Panguluri
Sent: Wednesday, March 05, 2008 8:09 AM
To: [email protected]
Subject: [JSch-users] JSch hangs in read
Sometimes with the few servers, The data read from input stream
and error stream are 0 bytes causing JSch to hang in read.
The code is as follows:
// Set the command
channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
InputStream in = channel.getInputStream();
InputStream inExt = channel.getExtInputStream();
BufferedReader brErr = new BufferedReader(new
InputStreamReader(inExt));
BufferedWriter bufWriter = new BufferedWriter(new
OutputStreamWriter(channel.getOutputStream()));
channel.connect();
// LOOP FOR FIXED TIME PERIOD until data is available
// Changing this code to wait indefinitely until channel
is closed is also hangning since the channel is never gettting closed.
while (fixed time) {
if (channel.isClosed() || data in any stream)
break;
Thread.sleep(100);
}
System.out.println("Stdout Bytes available : " +
in.available());
System.out.println("StdErr Bytes available : " +
inExt.available());
// The data available here is 0 bytes on both the
streams causing the subsequent read on Stream to hang.
BufferedReader br = new BufferedReader(new
InputStreamReader(in));
if (br != null) {
String line = null;
while ((line = br.readLine()) != null){
System.out.println(line);
}
}
Performing ssh directly to the server works well. This problem
is while running with the Jsch code.
Why does the data from servers is 0 bytes on both the streams.
How to write code such that data from servers appear correctly on
streams?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users