Org. Apache. Mina. Filter. codec. protocoldecoderexception: Java. NiO. bufferoverflowexception Solution

Source: Internet
Author: User

First, send dozens of small and small packages consecutively (<10 bytes) then, when a 64-byte package is suddenly sent, you will find that Mina will encounter the following error when using Mina to process big data reception:

Org. Apache. Mina. Filter. codec. protocoldecoderexception: Java. NiO. bufferoverflowexception (hexdump: 53 53 00 04)
At org. Apache. Mina. Filter. codec. protocolcodecfilter. messagereceived (protocolcodecfilter. Java: 242)
At org. Apache. Mina. Core. filterchain. defaultiofilterchain. callnextmessagereceived (defaultiofilterchain. Java: 417)
At org. Apache. Mina. Core. filterchain. defaultiofilterchain. Access $1200 (defaultiofilterchain. Java: 47)
At org. Apache. Mina. Core. filterchain. defaultiofilterchain $ entryimpl $1. messagereceived (defaultiofilterchain. Java: 765)
At org. Apache. Mina. Core. filterchain. iofilteradapter. messagereceived (iofilteradapter. Java: 109)
At org. Apache. Mina. Core. filterchain. defaultiofilterchain. callnextmessagereceived (defaultiofilterchain. Java: 417)
At org. Apache. Mina. Core. filterchain. defaultiofilterchain. firemessagereceived (defaultiofilterchain. Java: 410)
At org. Apache. Mina. Core. Polling. abstractpollingioprocessor. Read (abstractpollingioprocessor. Java: 710)
At org. Apache. Mina. Core. Polling. abstractpollingioprocessor. Process (abstractpollingioprocessor. Java: 664)
At org. Apache. Mina. Core. Polling. abstractpollingioprocessor. Process (abstractpollingioprocessor. Java: 653)
At org. Apache. Mina. Core. Polling. abstractpollingioprocessor. Access $600 (abstractpollingioprocessor. Java: 67)
At org. Apache. Mina. Core. Polling. abstractpollingioprocessor $ processor. Run (abstractpollingioprocessor. Java: 1124)
At org. Apache. Mina. util. namepreservingrunnable. Run (namepreservingrunnable. Java: 64)
At java. util. Concurrent. threadpoolexecutor $ worker. runtask (threadpoolexecutor. Java: 885)
At java. util. Concurrent. threadpoolexecutor $ worker. Run (threadpoolexecutor. Java: 907)
At java. Lang. thread. Run (thread. Java: 619)
Caused by: Java. NiO. bufferoverflowexception
At java. NiO. heapbytebuffer. Put (heapbytebuffer. Java: 182)
At org. Apache. Mina. Core. Buffer. abstractiobuffer. Put (abstractiobuffer. Java: 625)
At org. Apache. Mina. Core. Buffer. abstractiobuffer. Put (abstractiobuffer. Java: 1329)

After the analysis of Mina, this is made from the incorrect package length (that is, the length of the packet we send is greater than 64 bytes, but its bytebuffer size is only 64 bytes, this error occurs when we try to read 65th bytes );

Solution:

Acceptor. getsessionconfig (). setreadbuffersize (1024*1024); // sending buffer 1 m

Acceptor. getsessionconfig (). setreceivebuffersize (1024*1024); // The receiving buffer is 1 MB.

In actual application, you can set a reasonable size based on the business data packets.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.