//private static HttpClient HttpClient = Httpclientbuilder.create (). build ();
-
private static closeablehttpclient httpclient; / / = httpclientbuilder.create (). build (); //no timeout handling ...   
Static {
Requestconfig.builder Requestconfigbuilder = Requestconfig.custom ();
//client and server establish a connection timeout
Requestconfigbuilder.setconnecttimeout (30000);
//Get connection Timeout from connection pool
Requestconfigbuilder.setconnectionrequesttimeout (30000);
//After connection is established, request does not respond to timeout
Requestconfigbuilder.setsockettimeout (30000);
Httpclientbuilder Clientbuilder = Httpclientbuilder.create ();
Clientbuilder.setdefaultrequestconfig (Requestconfigbuilder.build ());
-
clientbuilder.setdefaultsocketconfig (Socketconfig.custom (). Setsotimeout (30000 After the connection is established, the request does not respond to the timeout
Clientbuilder.setkeepalivestrategy (new defaultconnectionkeepalivestrategy ());
HttpClient = Clientbuilder.build ();
Set timeout time when creating httpclient