inflearn logo
강의

Course

Instructor

Implementing a Spring Boot-based API template project to improve productivity

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

695

windguy19995381

20 asked

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();

}

.....

}

 

 

spring-boot jpa web-api

Answer 2

0

bgh79465479

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

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

bgh79465479

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

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

set('springCloudVersion', "2023.0.0")

image

0

windguy19995381

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

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

1

windguy19995381

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

답변 감사드립니다.

 

OAUTH2 질문

0

93

2

카카오토큰관련

0

79

2

auditing

0

75

1

전역에러처리질문

0

111

2

토큰 발급 관련 문의 드립니다.

0

129

2

이 흐름이 맞을까요??

0

126

2

OpenFeign을 어떤 상황에서 어떻게 사용하는지 감이 안옵니다...

0

216

2

도메인형 패키지 구조 질문

0

241

1

application.yml token 선언 시 오류

0

322

1

토큰발행시 500 INTERNAL_SERVER_ERROR

0

154

1

oauth 회원가입 시 필수 추가 정보는 어떤 식으로 받으시나요?

0

287

2

io.jsonwebtoken.security.WeakKeyException 해결방법

0

386

1

리프레시 토큰 사용 관련 문의 건

0

336

1

Xss 에서 WebConfig 오류 발생됩니다.

0

667

1

강사님 Swagger에 질문드립니다.

0

293

2

kakao token 발급 시 에러

0

729

2

아직 초반부분인데 질문이있습니다.

0

204

1

socialLoginApiService map 주입

0

290

1

전역 에러 처리 메시지 관리

0

605

2

안드로이드 스튜디오와 협업

0

643

2

String accessToken = authorizationHeader.split(" ")[1];은 accessToken이 맞나요?

0

310

1

SocialLoginApiServiceFactory 생성자 관련 질문입니다.

0

254

1

OAuthAttributes 클래스의 toMemberEntity의 파라미터로 memberType이 들어가야하는 이유가 궁금합니다.

0

444

2

feignClient의 consumes와 @RequestHeader는 같은 역할인가요?

0

929

1