타임아웃 Feign Client 해결 방법
SQL Server에서 쿼리를 실행하는 서비스를 사용할 때 응용 프로그램이 다음 오류를 발생시킵니다.FeignClient
.
에러:
스레드 "pool-10-thread-14" 의 예외입니다.재시도 가능예외: GET http://127.0.0.1:8876/processoData/search/buscaProcessoPorCliente?cliente=ELKTRO+-+TABALHISTA&estado=SP를 실행하는 동안 읽기 시간이 초과되었습니다.
마이 컨슈머 서비스:
@FeignClient(url="http://127.0.0.1:8876")
public interface ProcessoConsumer {
@RequestMapping(method = RequestMethod.GET, value = "/processoData/search/buscaProcessoPorCliente?cliente={cliente}&estado={estado}")
public PagedResources<ProcessoDTO> buscaProcessoClienteEstado(@PathVariable("cliente") String cliente, @PathVariable("estado") String estado);
}
내 YML:
server:
port: 8874
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
eureka:
client:
serviceUrl:
defaultZone: ${vcap.services.eureka-service.credentials.uri:http://xxx.xx.xxx.xx:8764}/eureka/
instance:
preferIpAddress: true
ribbon:
eureka:
enabled: true
spring:
application:
name: MyApplication
data:
mongodb:
host: xxx.xx.xxx.xx
port: 27017
uri: mongodb://xxx.xx.xxx.xx/recortesExtrator
repositories.enabled: true
solr:
host: http://xxx.xx.xxx.xx:8983/solr
repositories.enabled: true
이 문제를 해결할 방법을 아는 사람?
감사해요.
다음 속성을 에 추가합니다.application.properties
파일(밀리초 단위).
feign.client.config.default.connectTimeout=160000000
feign.client.config.default.readTimeout=160000000
사용하고 있다Feign.builder()
내 Feign 고객들을 인스턴스화 할 수 있어
설정하기 위해서connectTimeout
그리고.readTimeout
, 다음을 사용합니다.
Feign.builder()
...
.options(new Request.Options(connectTimeout, readTimeout))
.target(MyApiInterface.class, url);
이를 사용하여 API마다 다른 타임아웃을 설정할 수 있습니다.
방금 이 문제에 부딪혔어요.@spencergibb에서 제안하는 바와 같이 제가 사용하고 있는 회피책은 다음과 같습니다.링크를 참조해 주세요.
application.properties에 추가합니다.
# Disable Hystrix timeout globally (for all services)
hystrix.command.default.execution.timeout.enabled: false
# Increase the Hystrix timeout to 60s (globally)
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000
Java 컨피규레이션클래스에 추가합니다.
import feign.Request;
@Configuration
@EnableDiscoveryClient
@EnableFeignClients(basePackageClasses = { ServiceFeignClient.class })
@ComponentScan(basePackageClasses = { ServiceFeignClient.class })
public class FeignConfig {
/**
* Method to create a bean to increase the timeout value,
* It is used to overcome the Retryable exception while invoking the feign client.
* @param env,
* An {@link ConfigurableEnvironment}
* @return A {@link Request}
*/
@Bean
public static Request.Options requestOptions(ConfigurableEnvironment env) {
int ribbonReadTimeout = env.getProperty("ribbon.ReadTimeout", int.class, 70000);
int ribbonConnectionTimeout = env.getProperty("ribbon.ConnectTimeout", int.class, 60000);
return new Request.Options(ribbonConnectionTimeout, ribbonReadTimeout);
}
}
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=6000
ribbon.ReadTimeout=60000
ribbon.ConnectTimeout=60000
리본의 타임아웃이 히스트릭스보다 큰지 확인합니다.
메서드에 Options 인수를 추가하고 타임아웃을 동적으로 제어할 수 있습니다.
@FeignClient(url="http://127.0.0.1:8876")
public interface ProcessoConsumer {
@RequestMapping(method = RequestMethod.GET, value = "/processoData/search/buscaProcessoPorCliente?cliente={cliente}&estado={estado}")
PagedResources<ProcessoDTO> buscaProcessoClienteEstado(@PathVariable("cliente") String cliente, @PathVariable("estado") String estado,
Request.Options options);
}
다음과 같이 사용:
processoConsumer.buscaProcessoClienteEstado(..., new Request.Options(100, TimeUnit.MILLISECONDS,
100, TimeUnit.MILLISECONDS, true));
application.properties 파일에 다음 속성을 추가합니다.
값 5000은 밀리초 단위입니다.
feign.client.config.default.connectTimeout: 5000
feign.client.config.default.readTimeout: 5000
이 답을 보세요.그것은 나에게 효과가 있었다.또, 몇개의 조사를 실시해, 여기서 속성 메뉴얼을 찾았습니다.
https://github.com/Netflix/Hystrix/wiki/Configuration#intro
eureka: 클라이언트: eureka-server-read-seconds: 30
application.properties에 추가합니다.
feign.hystrix.enabled=false hystrix.command.default.default.hystrix.enabled.fthread.timeoutInMilliseconds=개요
언급URL : https://stackoverflow.com/questions/38080283/how-to-solve-timeout-feignclient
'programing' 카테고리의 다른 글
Bootstrap.yml 구성은 Spring Cloud 2020.0에서 더 이상 처리되지 않습니다. (0) | 2023.03.06 |
---|---|
TypeScript React에서 이미지 Import - "모듈을 찾을 수 없습니다" (0) | 2023.03.06 |
스크래피를 사용하여 AJAX를 사용하는 웹사이트에서 동적 콘텐츠를 스크래치할 수 있습니까? (0) | 2023.03.06 |
이 FB는 뭐야?Native Extensions.onready 콘솔 오류는 Facebook과 관련되어 있으며 어떻게 해결할 수 있습니까? (0) | 2023.03.06 |
ui-ipsec 상태 변경에서 $state.current.name를 반환하려면 어떻게 해야 합니까? (0) | 2023.03.01 |