2010-07-01 7 views

Répondre

5

J'ai donné sur jsch - et son API incroyablement inutile et commuté à:

http://www.cleondris.ch/opensource/ssh2/

(Ganymède SSH2). Je fais BEAUCOUP avec ssh dans la JVM et sur des mois d'utilisation de 24 heures, ganymede s'est avéré beaucoup plus fiable. Et plus agréable. Mon principal reproche est d'être apparemment incapable de définir des délais pour SCP.

+0

J'ai aussi été brûlé par JSch et il est terrible api et leurs docs: "... et seulement après la fermeture du canal (plus exactement, juste avant la fermeture du canal)". – Tnem

4

je souffrais le même problème et suis tombé sur ce dans le changelog jsch (http://www.jcraft.com/jsch/ChangeLog):

  • fonction: ajoutée « Channel.isClosed () '. Channel.getExitStatus() doit être invoqué après Channel.isClosed() == true.

donc frappé cette place: doit être appelée avant channel.disconnect(), sinon obtenir encore -1 question:

private static void waitForChannelClosure(ChannelExec ce, long maxwaitMs) { 

    log.info("waitForChannelClosure >>>"); 
    final long until = System.currentTimeMillis() + maxwaitMs; 

    try { 
     while (!ce.isClosed() && System.currentTimeMillis() < until) { 
      log.info("SFTP channel not closed .. waiting"); 
      Thread.sleep(250); 
     } 

    } catch (InterruptedException e) { 
     throw new RuntimeException("Interrupted", e); 
    } 

    if (!ce.isClosed()) { 
     throw new RuntimeException("Channel not closed in timely manner!"); 
    } 

}; 
+0

Bon à savoir! mais probablement ne pas revenir en arrière. Il y a quelques autres options là-bas maintenant (check-out jclouds pour eux) –

Questions connexes