apache/seatunnel · warning
Both channel and connection closing failed. Logging channel…
Error message
Both channel and connection closing failed. Logging channel exception and failing with connection exception
What it means
RabbitmqClient.close() closes channel then connection, keeping the first throwable in 't'. If closing the connection also fails and a channel exception was already captured, it logs the channel exception with this warning and continues to throw/report the connection exception, so neither failure is silently lost.
Solutions
- Check the logged channel exception and the propagated connection exception to identify the broker/network problem
- Verify RabbitMQ broker health and network connectivity at shutdown
- If both exceptions are always 'already closed', guard close with isOpen/state checks or make close idempotent and ignore AlreadyClosedException
Example fix
// before
try { channel.close(); } catch (IOException e) { t = e; }
try { connection.close(); } catch (IOException e) { ... }
// after
if (channel != null && channel.isOpen()) channel.close();
if (connection != null && connection.isOpen()) connection.close(); Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: connection must be open and reachable before use
if (connection == null || !connection.isOpen()) throw new IllegalStateException("rabbitmq connection not open"); Type guard
static boolean usable(com.rabbitmq.client.Connection c) { return c != null && c.isOpen(); } Try / catch
try { client.close(); } catch (Exception e) { /* close reports one exception; channel exception logged earlier */ log.warn("rabbitmq close partial failure", e); } Prevention
- Check broker health before stopping jobs
- Make close idempotent with isOpen checks
- Avoid closing during network partitions; rely on engine retry
- Keep rabbitmq client and connector versions aligned
When it happens
Trigger: close() is invoked while both channel.close() and connection.close() throw IOException — e.g. broker already unreachable — and the channel exception 't' is non-null when the connection close fails.
Common situations: RabbitMQ broker going down while the task is being cancelled; network partition during shutdown; closing a client whose connection was already dropped.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/10dde16dfde4a2e1.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-rabbitmq/src/main/java/org/apache/seatunnel/connectors/seatunnel/rabbitmq/client/RabbitmqClient.java:198
}
public void close() {
Exception t = null;
try {
if (channel != null && channel.isOpen()) {
channel.close();
}
} catch (IOException | TimeoutException e) {
t = e;
}
try {
if (connection != null && connection.isOpen()) {
connection.close();
}
} catch (IOException e) {
if (t != null) {
log.warn(
"Both channel and connection closing failed. Logging channel exception and failing with connection exception",
t);
}
t = e;
}
if (t != null) {
throw new RabbitmqConnectorException(
CLOSE_CONNECTION_FAILED,
String.format(
"Error while closing RMQ connection with queue %s at %s",
config.getQueueName(), config.getHost()),
t);
}
}
/** Declare the queue using configuration defaults. */
public void setupQueue() throws IOException {
if (StringUtils.isNotEmpty(config.getQueueName())) {View on GitHub (pinned to cf67b549a7)