Hi ymnk,
In my prior email, I discussed downloading and running a large Web Start
Application through a forwarded port, which caused my Session to disconnect.
After applying the patch from my prior email, my Sessions would no
longer close, but the performance was noticeably slower when compared to
performing the same test over a port forward with the native OpenSSH client.
The JNLP process involves opening multiple sockets concurrently, and
each connection may be very rapidly closed and reopened. I determined
that the performance issue was caused by the fact that no new
connections are processed for a forwarded port (PortWatcher.run()) until
a reply is received from the SSH Server on the prior connection
(channel.connect() blocks until the reply is received).
I modified ChannelDirectTCPIP.connect() to create the processing thread
prior to sending the CHANNEL_OPEN, and connect() returns immediately.
The thread will now send the command, wait for the reply, and then
continue to process the channel data as always. The performance
improvement in my case was dramatic.
Here is the patch diff to 0.1.45:
==== BEGIN PATCH =====
Index: src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java
===================================================================
--- src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java (revision 253)
+++ src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java (working copy)
@@ -64,6 +64,27 @@
if(!_session.isConnected()){
throw new JSchException("session is down");
}
+ if(io.in!=null){
+ thread=new Thread(this);
+ thread.setName("DirectTCPIP["+id+"] "+_session.getHost()+"
"+host+":"+port);
+ if(_session.daemon_thread){
+ thread.setDaemon(_session.daemon_thread);
+ }
+ thread.start();
+ }
+ }
+ catch(Throwable e){
+ io.close();
+ io=null;
+ Channel.del(this);
+ if (e instanceof JSchException) {
+ throw (JSchException) e;
+ }
+ }
+ }
+
+ private void sendConnect(Session _session) throws JSchException{
+ try{
Buffer buf=new Buffer(150);
Packet packet=new Packet(buf);
// send
@@ -123,20 +144,8 @@
}
connected=true;
-
- if(io.in!=null){
- thread=new Thread(this);
- thread.setName("DirectTCPIP thread "+_session.getHost());
- if(_session.daemon_thread){
- thread.setDaemon(_session.daemon_thread);
- }
- thread.start();
- }
}
catch(Exception e){
- io.close();
- io=null;
- Channel.del(this);
if (e instanceof JSchException) {
throw (JSchException) e;
}
@@ -145,12 +154,13 @@
public void run(){
+ try{
+ Session _session=getSession();
+ sendConnect(_session);
Buffer buf=new Buffer(rmpsize);
Packet packet=new Packet(buf);
int i=0;
- try{
- Session _session=getSession();
while(isConnected() &&
thread!=null &&
io!=null &&
==== END PATCH =====
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users