在Spring 5中,我们使用webclient通过SSL调用其他REST端点。当我们在wireshark上记录日志时,我们发现对于每个请求,SSL握手都在发生,并且花费大量时间。
这些是我的查询。
查询1: Webclient执行内部连接池。连接失效之前的到期时间是多少?
我们可以设置连接打开的时间,以便在已定义的连接上发送新请求以避免SSL握手吗?
是否存在避免每个请求进行SSL握手的设置?
查询2: 我们正在创建Webclient的bean,并在整个应用程序中使用它。我们需要做一些设置来启用连接池和重用现有连接以发送新请求。还有任何设置都可以避免每次SSL握手。
@Bean(name="productDefWebClient")
public WebClient productDefWebClient() {
ConnectionProvider elasticPool = ConnectionProvider.elastic("productDef-pool");
HttpClient httpClient = HttpClient.create(elasticPool).wiretap(true);
return WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient))
.defaultHeader("Accept","application/json")
.baseUrl("https://test-qa.test.com")
.build();
}