alibaba/canal · warning · CanalClientException
stop channel error
Error message
stop channel error
What it means
Thrown by CanalRabbitMQConsumer.disconnect when channel.close() raises IOException or TimeoutException during shutdown. The channel existed but could not be closed cleanly — usually because the underlying connection was already lost or the broker did not respond to the close handshake in time.
Source
Thrown at connector/rabbitmq-connector/src/main/java/com/alibaba/otter/canal/connector/rabbitmq/consumer/CanalRabbitMQConsumer.java:213
if (this.lastGetBatchMessage != null) {
this.lastGetBatchMessage.ack();
}
} catch (Throwable e) {
if (this.lastGetBatchMessage != null) {
this.lastGetBatchMessage.fail();
}
} finally {
this.lastGetBatchMessage = null;
}
}
@Override
public void disconnect() {
if (channel != null) {
try {
channel.close();
} catch (IOException | TimeoutException e) {
throw new CanalClientException("stop channel error", e);
}
}
if (connect != null) {
try {
connect.close();
} catch (IOException e) {
throw new CanalClientException("stop connect error", e);
}
}
}
}
View on GitHub (pinned to 87be50e876)
Solutions
- Treat channel-close failures as best-effort during shutdown: log and continue rather than aborting disconnect.
- Close the connection (which implicitly closes channels) if channel.close() is flaky.
- Avoid calling disconnect twice; guard with a null/closed check.
Example fix
// before
try {
channel.close();
} catch (IOException | TimeoutException e) {
throw new CanalClientException("stop channel error", e);
}
// after — best-effort close during shutdown
try {
channel.close();
} catch (IOException | TimeoutException | AlreadyClosedException e) {
logger.warn("Error closing rabbitmq channel during disconnect", e);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (channel == null || !channel.isOpen()) return;
Try / catch
try {
channel.close();
} catch (IOException | TimeoutException e) {
logger.warn("Error closing rabbitmq channel during disconnect", e);
} Prevention
- Treat shutdown close failures as best-effort.
- Guard disconnect with isOpen()/null checks to avoid double-close.
- Closing the connection implicitly closes channels if channel.close() is flaky.
When it happens
Trigger: channel.close() at line 210 fails. Causes: broker/connection already dropped so the channel close handshake times out; concurrent disconnect; broker slow to acknowledge close.
Common situations: Calling disconnect during/after a network partition; broker already gone; double-disconnect where the first close tore down the connection; slow broker under load causing the close to exceed its timeout.
Related errors
- stop connect error
- Stop RabbitMQ producer error
- Disconnect pulsar consumer error
- Start RabbitMQ producer error
- error
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/bdcb7e1d16fcae4b.
Report an issue: GitHub.