apache/seatunnel · error · ClickhouseConnectorException

Failed to close ssh client

Error message

Failed to close ssh client

What it means

ScpFileTransfer.close() wraps an IOException from sshClient.close() (after stop()) into SSH_OPERATION_FAILED with 'Failed to close ssh client'. Thrown during sink lifecycle shutdown when the SSH client teardown fails.

Source

Thrown at seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ScpFileTransfer.java:152

    @Override
    public void close() {
        if (clientSession != null && clientSession.isOpen()) {
            try {
                clientSession.close();
            } catch (IOException e) {
                throw new ClickhouseConnectorException(
                        ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,
                        "Failed to close ssh session",
                        e);
            }
        }
        if (sshClient != null && sshClient.isOpen()) {
            sshClient.stop();
            try {
                sshClient.close();
            } catch (IOException e) {
                throw new ClickhouseConnectorException(
                        ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,
                        "Failed to close ssh client",
                        e);
            }
        }
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Look for the first/underlying SSH error in the logs; this is typically a follow-on failure
  2. Avoid double-closing the transfer (check retry/cancel handling)
  3. Ensure the worker has enough threads/resources for the SSH client
  4. Retry the job and verify host connectivity
Defensive patterns

Strategy: try-catch

Try / catch

try {
    transfer.close();
} catch (ClickhouseConnectorException e) {
    log.warn("SSH client close failed during shutdown; treating as non-fatal", e);
}

Prevention

When it happens

Trigger: close() reaches sshClient.close() and it throws — usually a secondary symptom of an earlier connection failure, double-close from a concurrent cancel, or IO threads unable to shut down cleanly.

Common situations: Job cancellation racing sink close, prior SCP failure leaving the client broken, or thread/resource exhaustion on the SeaTunnel worker.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/70249631ba1c98c2. Report an issue: GitHub.