Hello,
After migrating to 4.3 from 4.1, I dont get keep-alive connections working.
My code is:
(
)
if (this.vkas == null) this.vkas = new KeepAliveStrategy(keepAliveDuration);
else this.vkas.setKeepAliveDuration(keepAliveDuration);
(...)
HttpClientBuilder hcBuilder =
HttpClients.custom().setConnectionManager(this.phccm).
disableCookieManagement().
setDefaultRequestConfig(this.rc).
setRetryHandler(this.rrh).
setKeepAliveStrategy(this.vkas);
// Add proxy.
if (proxyPort > 0) hcBuilder.setProxy(new HttpHost(proxyHost, proxyPort));
// Build 'HttpClient'.
this.objHttp = hcBuilder.build();
When I send a request, http log shows the following (with a keep alive of 20
seconds):
Auth cache not set in the context
Connection request: [route: {}->http://ws.rhodasol.es:80][total kept alive:
0; route allocated: 0 of 100; total allocated: 0 of 100]
Connection leased: [id: 148][route: {}->http://ws.rhodasol.es:80][total kept
alive: 0; route allocated: 1 of 100; total allocated: 1 of 100]
Connecting to ws.rhodasol.es/188.165.133.226:80
http-outgoing-148: Shutdown connection
http-outgoing-148: Close connection
Connection released: [id: 148][route: {}->http://ws.rhodasol.es:80][total
kept alive: 0; route allocated: 0 of 100; total allocated: 0 of 100]
In fact, my KeepAliveStrategy class is not called, because none of the
traces I put there are logged.
Should I enable keep alive in any way before calling the
setKeepAliveStrategy method?
Thanks,
Joan.