Ok I found the problem.
In ConnectionProtocol.java:
private void onMsgChannelExtendedData(SshMsgChannelExtendedData msg)
throws IOException {
Channel channel = getChannel(msg.getRecipientChannel());
if (channel == null) {
throw new IOException(
"Remote computer sent data for non existent channel");
}
>>>>> channel.getLocalWindow().consumeWindowSpace(msg.getChannelData().length);
channel.processChannelData(msg);
}
and in Channel.java
protected void processChannelData(SshMsgChannelExtendedData msg)
throws IOException {
synchronized (state) {
if (msg.getChannelData().length > localWindow.getWindowSpace()) {
throw new IOException(
"More data recieved than is allowed by the channel data window [" +
name + "]");
}
>>>>> long windowSpace = localWindow.consumeWindowSpace(msg.getChannelData().length);
if (windowSpace < getMinimumWindowSpace()) {
if (log.isDebugEnabled()) {
log.debug("Channel " + String.valueOf(localChannelId) +
" requires more window space [" + name + "]");
}
windowSpace = getMaximumWindowSpace() - windowSpace;
connection.sendChannelWindowAdjust(this, windowSpace);
localWindow.increaseWindowSpace(windowSpace);
}
onChannelExtData(msg);
Iterator it = eventListeners.iterator();
ChannelEventListener eventListener;
while (it.hasNext()) {
eventListener = (ChannelEventListener) it.next();
if (eventListener != null) {
eventListener.onDataReceived(this, msg.getChannelData());
}
}
}
}
We consume extended data's length in window space TWICE! So I removed the first one, from ConnectionProtocol.java and now everything is fine.