Architecture Pony
Nov 9, 2026 · Backend Development
Netty Framing Deep Dive: LengthFieldBasedFrameDecoder, TCP Stick/Unpack, and Protocol Pitfalls
This article analyzes three real-world Netty framing failures — half-pack JSON parsing, fixed-length decoder misalignment, and unbounded length-field OOM — then explains TCP's lack of message boundaries, compares three framing strategies, details LengthFieldBasedFrameDecoder's five parameters with diagrams, walks through ByteToMessageDecoder's cumulation and callDecode loop, shows Dubbo/gRPC protocol headers, and lists eight common codec pitfalls with fixes.