Solve the server-side Adjusted frame length exceeds 4096: 5637-discarded problem
1. Specific error
2. Error reason
2.1 Length format problem
2.2 Length size problem
3. Solution
1. Specific error
The following shows some error details.
io.netty.handler.codec.TooLongFrameException: Adjusted frame length exceeds 4096: 18247-discarded
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.fail(LengthFieldBasedFrameDecoder.java:503)
at io.netty.handler.codec.LengthFieldIfNecessary (LengthFieldBasedFrameDecoder.java:489)
AT io.netty.handler.codec.LengthFieldBasedFrameDecoder.exceededFrameLength (LengthFieldBasedFrameDecoder.java:376)
AT io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode (LengthFieldBasedFrameDecoder.java:419)
AT io.netty. handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:332)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:498)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:437)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext .java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext. channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel .java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel. nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989 )
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread. java:748)
2. Error reason
2.1 Length format problem
Netty’s own LengthFieldBasedFrameDecodr length coding protocol, the length offset value must be expressed in hexadecimal.
new LengthFieldBasedFrameDecoder(4*1024,0,2);
// Length bit: 000C means 12 length
// eg: 000C321453215435413415206753 (byte[] to hexadecimal representation)
2.2 Length size problem The
adjusted frame length exceeds 4096:18247- Has been discarded. I used the LengthFieldBasedFrameDecodr length protocol decoder when processing data packets on the netty server. Part of the code is as follows:
@Override
public void initChannel(SocketChannel ch) {
//Decoder of length protocol
ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(4*1024,0,2));
ch.pipeline().addLast(new SocketServerHandler() );//Control category
}
And the length agreement sets a maximum acceptable length of 4*1024 = 4096. Therefore, after the server receives more than 4096 bytes, the server discards it as a junk packet.
3. Solution
Change the maximum acceptable length of the decoder of the length protocol of the netty server to be long enough according to the needs.
new LengthFieldBasedFrameDecoder(20*1024,0,2);
Read More:
- [HBase Error]“java.lang.OutOfMemoryError: Requested array size exceeds VM limit”
- [Solved] the request was rejected because its size (11579386) exceeds the configured maximum (10485760)
- [Solved] No tf data. Actual error: Fixed Frame [world] does not exist
- [Solved] Git Push error: File: xxx 252.15 MB, exceeds 100.00 MB.
- R: Data frame index error “unexpected token”
- Arrays must all be same length [How to Solve]
- [Solved] Android DataBinding Error: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 fragment Changes to Fragm
- [Solved] yii Frame Error: Warning!symlink() has been disabled for security reasons
- Vue error in render: “typeerror: cannot read property ‘length’ of undefined”
- How to Solve Android Arouter Frame Autowired Error
- [Solved] KEIL Compile Error: Error: L6220E: Load region LR_IROM1 size (65552 bytes) exceeds limit (65536 bytes)……
- Browser Error: net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
- [Solved] Android7 8 Jack server SSL error: Jack server failed to (re)start, try ‘jack-diagnose’ or see Jack server log
- [Solved] Parcel Package Error: Cannot read property ‘length‘ of undefined
- [Solved] vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: “TypeError: Cannot read property ‘length‘
- Windows 7 IIS (HTTP Error 500.21-Internal Server Error) solution
- Go Slice Error: panic:runtime error:index out of range [0] with length 0 [Solved]
- Huawei kafka Authentication error: Server not found in Kerberos database (7) – LOOKING_UP_SERVER
- Stream to MemoryStream to solve Stream.Length error report This stream does not support search operations
- [Solved] error when starting dev server:Error: listen EACCES: permission denied 0.0.0.0:80 at Server.set