[英]How to set the connection Timeout for SOAP?
I am using the following sample code soap
我正在使用以下示例代码
soap
SSLConnectionSocketFactory socketFactory =
new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
HttpClient httpClient = HttpClients.custom()
.setSSLSocketFactory(socketFactory)
.addInterceptorFirst(new RemoHttpHeadersInterceptor())
.setMaxConnTotal(config.getDefaultMaxTotalConnections())
.setMaxConnPerRoute(config.getDefaultMaxRouteConnections())
.build();
return httpClient;
How can I set the connection timeout value?如何设置连接超时值? I am not able to find the
setTimeout
api anywhere.我无法在任何地方找到
setTimeout
api。
The way to configure it is to use a RequestConfig:配置它的方法是使用 RequestConfig:
Example:例子:
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
RequestConfig config = RequestConfig.custom()
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000)
.setSocketTimeout(5000).build();
HttpClients.custom()
.setDefaultRequestConfig(config)
.setSSLSocketFactory(socketFactory)
.addInterceptorFirst(new RemoHttpHeadersInterceptor())
.setMaxConnTotal(config.getDefaultMaxTotalConnections())
.setMaxConnPerRoute(config.getDefaultMaxRouteConnections())
.build();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.