• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

applycation.yml 의 readTimeout 이 적용이 안됩니다.

24.02.17 18:57 작성 조회수 129

0

Springboot 3.0.2

ext {

set('springCloudVersion', "2022.0.1")

}

 

최신 부트 3.2 에서는 호환 버전이 없어서 그런지 잘 안되서 위 와 같은 버전으로 하니깐 동작을 하는데,

타임아웃관련해서는 application.yml 에 설정한 부분이 적용안되는것 같습니다.

아래 readTimeout 부분에 마우스 오버 해보니,

"Cannot resolve configuration property 'feign.client.config.default.readTimeout' "

라고 표시 되더라구요.

혹시 버전에 따른 문제인지 코드부분을 점검해봐도 원인을 알 수 가 없네요.

확인 좀 부탁드릴게요~

 

 

feign:

client:

config:

default:

connectTimeout: 5000

readTimeout: 5000

 

@GetMapping("/health")

public ResponseEntity<HealthCheckResponseDto> healthCheck() {

try {

Thread.sleep(6000);

} catch (InterruptedException e) {

e.printStackTrace();

}

.....

}

 

 

답변 2

·

답변을 작성해보세요.

0

안녕하세요! 최근 문서를 보니 다음과 같이 변경이 되었네요!

https://docs.spring.io/spring-cloud-openfeign/docs/4.0.6/reference/html/

spring:
  cloud:
    openfeign:
      client:
        config:
          default:
            connectTimeout: 5000
            readTimeout: 5000

image

FeignClientExceptionErrorDecoder에서 오류가나는건은 RetryableException 생성자의 다섯번째 생성자retryAfter가 Date 1개만 존재하였는데 Long을 파라미터로 받는 파라미터가 추가되었습니다. 앞에 타입을 (Long)을 지정해주시면 정상적으로 수행될 것 입니다.

@Slf4j
public class FeignClientExceptionErrorDecoder implements ErrorDecoder {

    private ErrorDecoder errorDecoder = new Default();

    @Override
    public Exception decode(String methodKey, Response response) {
        log.error("{} 요청 실패, status : {}, reason : {}", methodKey, response.status(), response.reason());
        FeignException exception = FeignException.errorStatus(methodKey, response);
        HttpStatus httpStatus = HttpStatus.valueOf(response.status());
        if(httpStatus.is5xxServerError()) {
            return new RetryableException(
                    response.status(),
                    exception.getMessage(),
                    response.request().httpMethod(),
                    exception,
                    (Long) null,
                    response.request()
            );
        }
        return errorDecoder.decode(methodKey, response);
    }

}

 

0

안녕하세요!! 스프링부트 버전과 호환이 안되서 정상적으로 동작하지 않는것으로 보이네요

버전을 한번 아래처럼 바꿔보시겠어요?

set('springCloudVersion', "2023.0.0")

image

원데이님의 프로필

원데이

질문자

2024.02.20

버전을 변경하니깐 컴파일오류가 발생하네요.

yml 설정에서도 문제가 있는것 같구요 ㅜㅜ

 

image

F:\\api\spring-api-app\src\main\java\com\app\global\error\FeignClientExceptionErrorDecoder.java:21: error: reference to RetryableException is ambiguous

return new RetryableException(

^

both constructor RetryableException(int,String,HttpMethod,Throwable,Long,Request) in RetryableException and constructor RetryableException(int,String,HttpMethod,Throwable,Date,Request) in RetryableException match

 

 

image

원데이님의 프로필

원데이

질문자

2024.02.22

오류 없이 정상 동작하네요.

답변 감사드립니다.