apache/seatunnel · error · ClickhouseConnectorException
Failed to close ssh session
Error message
Failed to close ssh session
What it means
RsyncFileTransfer.close() wraps any IOException thrown while closing the Apache SSHD clientSession into a ClickhouseConnectorException with SSH_OPERATION_FAILED. This fires during sink cleanup when the SSH connection to the remote host is already broken or the session teardown fails. It signals that resources may not have been released cleanly.
Source
Thrown at seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/RsyncFileTransfer.java:180
}
}
@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
- Verify network stability and SSH server KeepAlive/timeout settings between SeaTunnel worker and the ClickHouse host
- Check sshd logs on the remote host for connection resets around the failure time
- Retry the job; if intermittent, this is a transient network issue
- Upgrade connector/sshd-common dependency if the close-failure stems from a known Apache SSHD bug
Example fix
// before: no keepalive configured SshClient sshClient = SshClient.setUpDefaultClient(); sshClient.start(); // after: enable heartbeats so idle sessions are not reaped ClientFactoryManager manager = sshClient; manager.setKeepAliveProvider(KeepAliveProvider.KEEP_ALIVE); manager.setProperty(ClientFactoryManager.HEARTBEAT_INTERVAL, 30000);
Defensive patterns
Strategy: try-catch
Validate before calling
// before job: verify SSH reachability ssh -o ConnectTimeout=5 -o BatchMode=yes user@host true && echo OK
Try / catch
try {
sink.close();
} catch (ClickhouseConnectorException e) {
if (e.getErrorCode() == ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED) {
log.warn("SSH session close failed (possibly already dead connection), continuing", e);
} else { throw e; }
} Prevention
- Configure SSH keepalive/heartbeat intervals to survive idle periods
- Avoid firewall/NAT idle timeouts shorter than job duration
- Monitor sshd logs for dropped connections
When it happens
Trigger: Sink close() is called and clientSession.close() throws IOException — typically because the network connection dropped mid-job, the SSH server closed the connection abruptly, or the session was already half-closed by a timeout.
Common situations: Long-running ClickHouse rsync-based file transfers where an idle SSH session was reaped by a firewall/NAT, remote ClickHouse host restarted during the job, or SSH server IdleTimeout terminated the session before close().
Related errors
- Failed to close ssh client
- Failed to close ssh session
- Failed to close ssh client
- Failed to connect to host: " + host + " by user: " + user +
- Failed to connect to host: " + host + " by user: " + user +
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/686ba32f5db41460.
Report an issue: GitHub.