apache/seatunnel · error · ClickhouseConnectorException

Failed to close ssh session

Error message

Failed to close ssh session

What it means

ScpFileTransfer.close() wraps an IOException from clientSession.close() into SSH_OPERATION_FAILED with the message 'Failed to close ssh session'. Identical in shape to the rsync variant but on the SCP transfer path; it fires during sink shutdown.

Source

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

        }
    }

    @Override
    public void transferAndChown(List<String> sourcePaths, String targetPath) {
        if (sourcePaths == null) {
            throw new ClickhouseConnectorException(
                    CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT, "sourcePath is null");
        }
        sourcePaths.forEach(sourcePath -> transferAndChown(sourcePath, targetPath));
    }

    @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. Check logs for the original SSH failure that broke the session; this is often secondary
  2. Verify network stability and SSH keepalive/idle timeouts between worker and host
  3. Retry the job; intermittent failures indicate transient network problems
  4. Confirm sshd is healthy and not rate-limiting or dropping connections
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-job SSH reachability check
ssh -o ConnectTimeout=5 user@host true && echo OK

Try / catch

try {
    transfer.close();
} catch (ClickhouseConnectorException e) {
    log.warn("SCP session close failed; likely already broken connection", e);
}

Prevention

When it happens

Trigger: close() is invoked and the SCP clientSession.close() throws IOException — connection already dropped, server closed the session, or teardown raced with an in-flight transfer.

Common situations: Idle SCP session killed by firewall/NAT during a long job, remote host rebooted, or session already errored from a failed transfer leaving close to fail too.

Related errors


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