Skip to content

Configuring the underlying AHC provider

riordanmr edited this page Dec 24, 2014 · 2 revisions

By default, the wasync's HTTP runtime, AsyncHttpClient, uses the powerful Netty's framework as the HTTP processor. There might be environments where you can't use Netty. Fortunately, the AsyncHttpClient library supports another http runtime: the GrizzlyAsyncHttpProvider.

To change providers, all you need to do is:

AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(new AsyncHttpClientConfig.Builder().build()));

You can also configure the default Netty Provider. As an example, you can increase the NettyAsyncHttpProvider default buffer size by doing:

NettyAsyncHttpProviderConfig config = new NettyAsyncHttpProviderConfig();
config.setProperty(NettyAsyncHttpProviderConfig.HTTP_CLIENT_CODEC_MAX_CHUNK_SIZE, 32000);

AsyncHttpClientConfig c = new AsyncHttpClientConfig().setAsyncHttpClientProviderConfig(config).build();
AsyncHttpClient ahc = new AsyncHttpClient(new NettyAsyncHttpProvider(config));
...
Socket socket = client.create(client.newOptionsBuilder().runtime(ahc).build());
Clone this wiki locally