pentaho/pentaho-kettle · error · SshConnectionException

SSH connection failed - session is null

Error message

SSH connection failed - session is null

What it means

establishSession calls cf.getSession() after a successful connect but defends against the impossible-per-API case of a null ClientSession, throwing SshConnectionException('SSH connection failed - session is null'). This is an internal-invariant style check in MinaSshConnection; it indicates the MINA future reported connected but produced no session.

Solutions

  1. Log and report the MINA SSHD version in use; upgrade org.apache.sshd to a current release
  2. Retry the connect — often transient state race
  3. Check the full stack trace for a concurrent disconnect closing the session
  4. Open an issue with the Pentaho Kettle project if reproducible
Defensive patterns

Strategy: retry

Validate before calling

// after connect()
if ( !connection.isConnected() ) { throw new IllegalStateException( "Connection not established; cannot use session" ); }

Try / catch

try { conn.connect(); }
catch ( SshConnectionException e ) {
  if ( e.getMessage().contains( "session is null" ) ) { retryConnectWithBackoff( conn ); } // transient MINA state issue
  else throw e;
}

Prevention

When it happens

Trigger: connect() proceeds past waitForConnection with connected=true, yet ConnectFuture.getSession() returns null — effectively a MINA SSHD state anomaly or race in future completion.

Common situations: Rarely user-caused; seen with unusual MINA SSHD version behavior, race conditions in future completion, or custom/patched SSHD library builds.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/0e5887cc9acd2f2f. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/core/ssh/mina/MinaSshConnection.java:277

    if ( !connected ) {
      if ( connectTimeout > 0 ) {
        throw new SshTimeoutException( "SSH connection timed out after " + connectTimeout + "ms" );
      }
      throw new SshTimeoutException( "SSH connection failed while waiting with no configured timeout" );
    }

    if ( !cf.isConnected() ) {
      Throwable cause = cf.getException();
      throw new SshConnectionException( "SSH connection failed", cause );
    }
  }

  private ClientSession establishSession( ConnectFuture cf ) throws SshConnectionException {
    ClientSession s = cf.getSession();

    if ( s == null ) {
      throw new SshConnectionException( "SSH connection failed - session is null" );
    }

    return s;
  }

  private void authenticateSession() throws SshConnectionException {
    log( DEBUG, "Starting SSH authentication - Auth type: " + config.getAuthType() );
    boolean authed = tryPublicKeyAuthentication();

    if ( !authed ) {
      log( DEBUG, "Public key authentication failed or not configured, trying password authentication" );
      authed = tryPasswordAuthentication();
    }

    if ( !authed ) {
      log( ERROR, "All SSH authentication methods failed" );
      throw new SshAuthenticationException( "SSH authentication failed" );
    } else {

View on GitHub (pinned to f3058517a1)