{"record":{"id":"bce550eb5e2dc4b0","repo":"alibaba/canal","slug":"expect-handshake-but-found-other-type-bce550","errorCode":null,"errorMessage":"expect handshake but found other type.","messagePattern":"expect handshake but found other type\\.","errorType":"exception","errorClass":"CanalClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java","lineNumber":161,"sourceCode":"\n    private InetSocketAddress doConnect() throws CanalClientException {\n        try {\n            channel = SocketChannel.open();\n            channel.socket().setSoTimeout(soTimeout);\n            SocketAddress address = getAddress();\n            if (address == null) {\n                address = getNextAddress();\n            }\n            channel.connect(address);\n            readableChannel = Channels.newChannel(channel.socket().getInputStream());\n            writableChannel = Channels.newChannel(channel.socket().getOutputStream());\n            Packet p = Packet.parseFrom(readNextPacket());\n            if (p.getVersion() != 1) {\n                throw new CanalClientException(\"unsupported version at this client.\");\n            }\n\n            if (p.getType() != PacketType.HANDSHAKE) {\n                throw new CanalClientException(\"expect handshake but found other type.\");\n            }\n            //\n            Handshake handshake = Handshake.parseFrom(p.getBody());\n            supportedCompressions.add(handshake.getSupportedCompressions());\n            //\n            ByteString seed = handshake.getSeeds(); // seed for auth\n            String newPasswd = password;\n            if (password != null) {\n                // encode passwd\n                newPasswd = SecurityUtil.byte2HexStr(SecurityUtil.scramble411(password.getBytes(), seed.toByteArray()));\n            }\n\n            ClientAuth ca = ClientAuth.newBuilder()\n                .setUsername(username != null ? username : \"\")\n                .setPassword(ByteString.copyFromUtf8(newPasswd != null ? newPasswd : \"\"))\n                .setNetReadTimeout(idleTimeout)\n                .setNetWriteTimeout(idleTimeout)\n                .build();","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java#L143-L179","documentation":"Error \"expect handshake but found other type.\" thrown in alibaba/canal.","triggerScenarios":"Thrown at client/src/main/java/com/alibaba/otter/canal/client/impl/SimpleCanalConnector.java:161 when the library encounters an invalid state.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}