Apache非同期httpクライアントでリダイレクト戦略を設定するにはどうすればよいですか? 私はこのようなものを持っています(スカラコード)。コメント付きのコードは期待どおりに機能しますが、1 秒あたり 1 つのホストに対して 4 つを超える同時要求を実行することはできません。
object HttpClientManager {
def createHttpClient(): CloseableHttpAsyncClient = { //cm: NHttpClientConnectionManager
/*
val httpClient = HttpAsyncClients
.custom()
.setDefaultRequestConfig(config)
//.setConnectionManager(cm)
.build()
*/
// val config = RequestConfig.custom()
// .setSocketTimeout(3000)
// .setConnectTimeout(3000).build();
val socketConfig = SocketConfig.custom()
.setSoTimeout(15000)
.build();
val connectionConfig = ConnectionConfig.custom()
.setBufferSize(8 * 1024)
.setFragmentSizeHint(8 * 1024)
.build();
val ioreactor = new DefaultConnectingIOReactor();
val mgr = new PoolingNHttpClientConnectionManager(ioreactor);
mgr.setDefaultSocketConfig(socketConfig);
mgr.setDefaultConnectionConfig(connectionConfig);
mgr.setDefaultMaxPerRoute(100)
mgr.setMaxTotal(200)
val httpclient = HttpAsyncClients.createMinimal(mgr);
httpclient.start()
httpclient
}
}