Apache Mina output message size modified to address the limit of 98304 maximum data received by the HTTP service client

Source: Internet
Author: User

A recent Mina-based application, managed with HTTP services, is also implemented by the HTTP service Mina, and the runtime discovers that if the data returned by HTTP is greater than
98304, the client will receive not completely toss for 2 days, only to find that Mina each send the message size is 98304, I did not find the method of sending multiple times, and not sure how many times sent will not be received by the client, finally reference some information, to find ways to modify the size, The first thing you need to know is the total size of the data you want to send, and the way I implement it is to add a total size httpresponsemessage inside the Httpresponseencoder (Messageencoder) inside the Encode room method inside the Buf.flip modified to:
Msg.settotal (Buf.position ());//sets the total size of the actual data size
Buf.flip (). Shrink ();
Then send the modification where the data is sent:

int s = Session.getconfig (). Getmaxreadbuffersize (); Writefuture WF;WF = session.write (response);//must call this first, encoder will be called before it can be set to the total size, the following can be taken to int t = response.gettotal (); if (t >s*1.5) {//Send buffer size is 1.5 times times the read buffer int new_s = (int) (Math.ceil (t/1.5) +), Session.getconfig (). Setmaxreadbuffersize (New_ s);//set to large enough}wf.setwritten (); wf.awaituninterruptibly (); if (!wf.isdone ()) {System.out.printf ("not send------------- ------------------------------\ n ");}

Always think my method is very earth, but it works, seek master

My group, group name is: phper& page Tour &mobile&u3d 2D
Group number: 95303036
Dabigatran in addition to asking questions, please remember to help others, thank you.
----------------------------------to send an advertisement again. Click the map to enter, support my friend.

Group name is: phper& page Tour &mobile&u3d 2D
Group number: 95303036
Dabigatran in addition to asking questions, please remember to help others, thank you.
----------------------------------again send an advertisement, buy furniture on the net cheap 1/4, also parcel mail. Point chart into, support my wife.

Apache Mina output message size modified to address the limit of 98304 maximum data received by the HTTP service client

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.