In my code I am trying to keep the Jsch session active cause I expect many interactions with the server will happen. And the logic is:
However I found if #1 give me a "file not found", #2 will fail with the same exception at here:
Header header=new Header();
header=header(buf, header);
int length=header.length;
int type=header.type;
fill(buf, length);
if(type!=SSH_FXP_STATUS && type!=SSH_FXP_HANDLE){
throw new SftpException(SSH_FX_FAILURE, "invalid type="+type);
}
if(type==SSH_FXP_STATUS){
int i=buf.getInt();
>>>> throwStatusError(buf, i);
}
byte[] handle=buf.getString(); // handle
byte[] data=null;
So the question is why the new channel got the same error with previous channel even before I put a single byte to the channel?
Okay. So the issue is caused I've use the session to get an non-existing file before and the input stream returned by the get operation is not closed. That triggers all following operation on the same session throw out SftpException with id == 2, i.e. file not found