alibaba/canal · error · CanalClientException
expect handshake but found other type.
Error message
expect handshake but found other type.
What it means
Error "expect handshake but found other type." thrown in alibaba/canal.
Source
Thrown at client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java:161
private InetSocketAddress doConnect() throws CanalClientException {
try {
channel = SocketChannel.open();
channel.socket().setSoTimeout(soTimeout);
SocketAddress address = getAddress();
if (address == null) {
address = getNextAddress();
}
channel.connect(address);
readableChannel = Channels.newChannel(channel.socket().getInputStream());
writableChannel = Channels.newChannel(channel.socket().getOutputStream());
Packet p = Packet.parseFrom(readNextPacket());
if (p.getVersion() != 1) {
throw new CanalClientException("unsupported version at this client.");
}
if (p.getType() != PacketType.HANDSHAKE) {
throw new CanalClientException("expect handshake but found other type.");
}
//
Handshake handshake = Handshake.parseFrom(p.getBody());
supportedCompressions.add(handshake.getSupportedCompressions());
//
ByteString seed = handshake.getSeeds(); // seed for auth
String newPasswd = password;
if (password != null) {
// encode passwd
newPasswd = SecurityUtil.byte2HexStr(SecurityUtil.scramble411(password.getBytes(), seed.toByteArray()));
}
ClientAuth ca = ClientAuth.newBuilder()
.setUsername(username != null ? username : "")
.setPassword(ByteString.copyFromUtf8(newPasswd != null ? newPasswd : ""))
.setNetReadTimeout(idleTimeout)
.setNetWriteTimeout(idleTimeout)
.build();View on GitHub (pinned to 87be50e876)
Solutions
- Make sure the client connects to the canal server TCP port (default 11111), not the admin or HTTP port.
- Verify no proxy or middlebox is rewriting the initial handshake bytes between client and server.
- Match client and server canal versions so both speak the same handshake protocol.
When it happens
Trigger: Thrown at client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java:161 when the library encounters an invalid state.
Common situations: Received a non-handshake packet during connect. Close the connection immediately, do not reuse the channel, and treat this as a protocol mismatch or a wrong-port target.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/bce550eb5e2dc4b0.
Report an issue: GitHub.