@Bean
public ApacheHttpClient client() {
RequestConfig config = RequestConfig.custom().setConnectTimeout(30)
.setSocketTimeout(30).build();
CloseableHttpClient httpClientObject = HttpClientBuilder.create()
.setDefaultRequestConfig(config)
.build();
return new ApacheHttpClient(httpClientObject);
}
@Autowired
public HTTPRequestClient(Decoder decoder, Encoder encoder, ApacheHttpClient client) {
this.client = client;
setHttpRequestAdaptor(Feign.builder()
.client(client)
.encoder(encoder)
.decoder(decoder)
.logLevel(feign.Logger.Level.FULL)
.target(Target.EmptyTarget.create(HTTPRequestAdaptor.class)));
}
连接超时和套接字超时不起作用。需要哪些属性与 feign http 客户端配合使用?我一直在使用
feign.httpclient.enabled=true
feign.httpclient.connection-timeout=2
但它没有奏效。