alibaba/canal · error · IOException
end of stream when reading header
Error message
end of stream when reading header
What it means
Error "end of stream when reading header" thrown in alibaba/canal.
Source
Thrown at client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java:425
}
}
private byte[] readNextPacket(ReadableByteChannel channel) throws IOException {
synchronized (readDataLock) {
readHeader.clear();
read(channel, readHeader);
int bodyLen = readHeader.getInt(0);
ByteBuffer bodyBuf = ByteBuffer.allocate(bodyLen).order(ByteOrder.BIG_ENDIAN);
read(channel, bodyBuf);
return bodyBuf.array();
}
}
private void read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException {
while (buffer.hasRemaining()) {
int r = channel.read(buffer);
if (r == -1) {
throw new IOException("end of stream when reading header");
}
}
}
private synchronized void initClientRunningMonitor(ClientIdentity clientIdentity) {
if (zkClientx != null && clientIdentity != null && runningMonitor == null) {
ClientRunningData clientData = new ClientRunningData();
clientData.setClientId(clientIdentity.getClientId());
clientData.setAddress(AddressUtils.getHostIp());
runningMonitor = new ClientRunningMonitor();
runningMonitor.setDestination(clientIdentity.getDestination());
runningMonitor.setZkClient(zkClientx);
runningMonitor.setClientData(clientData);
runningMonitor.setListener(new ClientRunningListener() {
public InetSocketAddress processActiveEnter() {
InetSocketAddress address = doConnect();View on GitHub (pinned to 87be50e876)
Solutions
- Check network stability between client and server; the connection was closed mid-read.
- Increase socketTimeout on the connector if the server is slow to respond under load.
- Reconnect the connector and resume consumption from the last acked position.
When it happens
Trigger: Thrown at client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java:425 when the library encounters an invalid state.
Common situations: Stream ended mid-header. Reconnect with a fresh channel rather than resuming reads, and check server health and network intermediaries for dropped connections.
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/0a9d05c17401d9f7.
Report an issue: GitHub.