How to increase default buffer size in AsyncHttpClient. I am using following code to read messages from a streaming server(Http long pooling).
When server sends a message longer than 8KB, then my message is divided in to chunks.
Ex:-
Original message :-
This is my Test Message
Received message :-
This is my
Test
Message
Is there any way to increase buffer size? So that i receive entire message in one part?
My Code
AsyncHttpClientConfig.Builder config = new AsyncHttpClientConfig.Builder()
.setConnectionTimeoutInMs(120000)
.setRequestTimeoutInMs(-1)
.setIdleConnectionTimeoutInMs(120000)
.setMaxConnectionLifeTimeInMs(-1);
AsyncHttpClient client = new AsyncHttpClient(config.build());
Future<String> f = client.prepareGet("http://IP:PORT/context/test").execute(
new AsyncHandler<String>() {
private ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@Override
public STATE onBodyPartReceived(
HttpResponseBodyPart bodyPart) throws Exception {
String data = new String(bodyPart.getBodyPartBytes());
System.out.println("My Message : ---------------------------- >" + data);
return STATE.CONTINUE;
}
});
f.get();
}
I tried to accumulate message body parts, but that require separate logic in server size to know end of message.
Thanks,
Ravi