You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Joan grupoventus <jo...@grupoventus.com> on 2021/01/08 15:57:27 UTC

Response buffer size

Hello,

 �

I’m using HttpClient 4.5.7. reading responses from a backend through a ‘HttpAsyncResponseConsumer’ on the ‘consumeContent’ method  in this way:

 �

while ( (numBytesRead = decoder.read(this.bbuf)) > 0 ) {

( . . . )

}

  

where  this.bbuf = ByteBuffer.allocate(32768);

  

  

The buffer size in the async http instance is configured in this way (‘phccm’ is  a ‘PoolingNHttpClientConnectionManager’):

this.phccm.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSize(32768).setFragmentSizeHint(32768).build()

  

And on the IOReactor:

IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setRcvBufSize(32768) ...

  

  

But when we start reading the response on the consume content method, the byte buffer is filled out just with 16K of data:

Cycle 0 :: bytes read = 15812, total size (K) = 15

Cycle 1 :: bytes read = 16368, total size (K) = 31

Cycle 2 :: bytes read = 16376, total size (K) = 47

Cycle 3 :: bytes read = 16384, total size (K) = 63

Cycle 4 :: bytes read = 16376, total size (K) = 79

Cycle 5 :: bytes read = 16384, total size (K) = 95

Cycle 6 :: bytes read = 16376, total size (K) = 111

Cycle 7 :: bytes read = 16384, total size (K) = 127

 �

What am I missing?

 �

Thanks,

 �

Joan.

 �


Re: Response buffer size

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Might depend on the server block size or tcp buffers, as it will not wait till the buffers are filled, it only processes the data available in a single read.

Gruss
Bernd


--
http://bernd.eckenfels.net
________________________________
Von: Joan grupoventus <jo...@grupoventus.com>
Gesendet: Friday, January 8, 2021 4:57:27 PM
An: 'HttpClient User Discussion' <ht...@hc.apache.org>
Betreff: Response buffer size

Hello,

 �

I’m using HttpClient 4.5.7. reading responses from a backend through a ‘HttpAsyncResponseConsumer’ on the ‘consumeContent’ method  in this way:

 �

while ( (numBytesRead = decoder.read(this.bbuf)) > 0 ) {

( . . . )

}



where  this.bbuf = ByteBuffer.allocate(32768);





The buffer size in the async http instance is configured in this way (‘phccm’ is  a ‘PoolingNHttpClientConnectionManager’):

this.phccm.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSize(32768).setFragmentSizeHint(32768).build()



And on the IOReactor:

IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setRcvBufSize(32768) ...





But when we start reading the response on the consume content method, the byte buffer is filled out just with 16K of data:

Cycle 0 :: bytes read = 15812, total size (K) = 15

Cycle 1 :: bytes read = 16368, total size (K) = 31

Cycle 2 :: bytes read = 16376, total size (K) = 47

Cycle 3 :: bytes read = 16384, total size (K) = 63

Cycle 4 :: bytes read = 16376, total size (K) = 79

Cycle 5 :: bytes read = 16384, total size (K) = 95

Cycle 6 :: bytes read = 16376, total size (K) = 111

Cycle 7 :: bytes read = 16384, total size (K) = 127

 �

What am I missing?

 �

Thanks,

 �

Joan.

 �


Re: Response buffer size

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2021-01-08 at 16:57 +0100, Joan grupoventus wrote:
> Hello,
> 
>  �
> 
> I’m using HttpClient 4.5.7. reading responses from a backend through
> a ‘HttpAsyncResponseConsumer’ on the ‘consumeContent’ method  in this
> way:
> 
>  �
> 
> while ( (numBytesRead = decoder.read(this.bbuf)) > 0 ) {
> 
> ( . . . )
> 
> }
> 
>   
> 
> where  this.bbuf = ByteBuffer.allocate(32768);
> 
>   
> 
>   
> 
> The buffer size in the async http instance is configured in this way
> (‘phccm’ is  a ‘PoolingNHttpClientConnectionManager’):
> 
> this.phccm.setDefaultConnectionConfig(ConnectionConfig.custom().setBu
> fferSize(32768).setFragmentSizeHint(32768).build()
> 
>   
> 
> And on the IOReactor:
> 
> IOReactorConfig ioReactorConfig =
> IOReactorConfig.custom().setRcvBufSize(32768) ...
> 
> 

Please post a complete test application I could run locally to
reproduce the issue.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org