When using closeablehttpclient to make a remote service call, the first time is very slow or even the request times out

CSDN Q & A 2022-02-13 05:55:50 阅读数:878

using closeablehttpclient make remote service

Baidu for a while , It should be the first time you need to establish a connection , After a period of time, because the connection has been established, the request is very fast , How to solve the problem of slow connection for the first time

 CloseableHttpClient httpClient = (args != null && args.length == 1) ? getHttpClient(args[0]) : getHttpClient(); // Perform the requested  CloseableHttpResponse response = httpClient.execute(httpPost);

Take the answer :

Now? spring Already available RestTemplate Make interface requests , It's easy to use , Time consuming is not high

Other answers 2:

use openFegin Well

copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130555483360.html