Skip to content

com.jcraft.jsch.JSchException: Packet corrupt #1032

Description

@cdprete

Hello.

I'm using the latest version of the library and, almost every time, on the first attempt of making the Session establishing a connection I've the same issue as in #614.
The strange thing is that, on the next retry, it works fine with no issue.

Therefore, I had simply the idea to reconnect (even though it would be nice if the library would do it automatically given that I'm configuring the MaxAuthAttempts) by doing something like the following:

Session session = ... get the session
try {
   session.connect(timeout);
} catch(JSchException ex) {
   if(ex.getMessage().contains("Auth fail")) {
       session.disconnect();
       session.connect(); // it fails with the reported error here
   } else {
      throw new RuntimeException(ex);
   }
}

This StackOverflow comment https://stackoverflow.com/questions/27838523/jschexception-packet-corrupt/30855201#30855201 is somehow suggesting that, even if I call disconnect, the Session object is somehow holding this packet.

Would it be possible to ensure that, if disconnect is called, the state of the Session object gets wiped out so that the next call to connect would behave like if such an object was created for the first time?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions