Uploaded image for project: 'OpenICF'
  1. OpenICF
  2. OPENICF-1445

SSH connector: Stale or disconnected SSH sessions are not detected when borrowing from the pool

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.18.0
    • 1.5.19.1
    • SSH Connector
    • None
    • 54898

    Description

      When an SSH connection dies, either by the server ending the session, or a connectivity problem, the "checkAlive()" method fails to identify sessions that are no longer connected.

      At present it does this check

      		//Check if the Connection is still active
              try {
                  connection.getSession().sendKeepAliveMsg();
              } catch (Exception e) {
                  throw new ConnectionBrokenException("Failed to send Keep-Alive message");
              }
      

      However, sending a keep alive message doesn't appear to cause an exception on a dead connection.

      I found that if you actually check that the session is connected and then throw an exception if it isn't it is able to reconnect and use a working connection.

              //Check if the Connection is still active
              try {
                  connection.getSession().sendKeepAliveMsg();
              } catch (Exception e) {
                  throw new ConnectionBrokenException("Failed to send Keep-Alive message");
              }
              
              // Ensure that the session is actually connected, as the session might have gone stale
              if (!connection.getSession().isConnected()) {
              	throw new ConnectionBrokenException("Session is not connected");
              }
      

      I found the easiest way to test this is on the SSH server, simply kill the ssh connection for the user, and then try running a test or a search even, and it should fail.

      After the above fix it transparently reconnects and starts working again.

      Attachments

        Activity

          People

            gael Gael Allioux
            japearson Joel Pearson
            Son Nguyen Son Nguyen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: