본문으로 바로가기

[에러] RoundRobinLoadBalancer : No servers available for service

category MSA 2023. 1. 12. 20:48

에러

Spring Cloud Gateway route 추가 시 발생한 에러.

작동은 이상이 없으나 Gateway를 통해 다른 api 요청 시 발생함.

 

에러 내용

RoundRobinLoadBalancer      : No servers available for service [application.name]

 

원인

나 같은 경우는 uri 정보가 맞지 않았음.

Gateway의 route 정보와

Eureka Client의 정보가 일치해야 함.

 

해결

[Eureka Client]

 
server:
  port: ${port:0}
  servlet:
    context-path: /mypath


spring:
  application:
    name: myappname

 

[Eureka Gateway]

spring:
  application:
    name: myGateway
  cloud:
    gateway:
      routes:
        - id: mymymy            #유레카 서버에 등록되는 이름
          uri: lb://myappname   #유레카 서버에서 application.name 찾아서 그곳으로 요청을 보낸다.(upper, lower 구분 없음)
          predicates:
            - Path=/mypath/**   #mypath로 들어오는 애들은 myappname instance로 간주한다. (predicate: 근거를 두다, 단정하다)

 

[매칭표]

[Eureka Client] 매칭 [Eureka Gateway]
context-path = routes.predicates
application.name = routes.uri

gateway 와 api의 설정 값이 일치 하는지 확인 후 해결하였다.