How to solve 503 error code?

Time:2021-8-26

POM file dependency

<dependencies>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>
<!--gateway fhadmin.org-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
    <version>3.0.2</version>
</dependency>
<!--spring-boot fhadmin.org-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

</dependencies>

clickMobile GamesLabel and drag to move
The related dependencies of Nacos I added in the parent component are as follows:

<dependency>

<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>${nacos.version}</version>

</dependency>
<!–alibaba fhadmin.org–>
<dependency>

<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${nacos.version}</version>

</dependency>

Click and drag to move
The version of Nacos is as follows:

<properties>

<nacos.version>2021.1</nacos.version>

</properties>

Click and drag to move
The application.yml file of gateway is configured as follows:

fhadmin.org

server:
port: 9040
spring:
application:

name: gateway

cloud:

gateway:
  routes:
    - id: consumer
      uri: lb://consumer
      #          uri: 
      predicates:
        - Path=/**
nacos:
  discovery:
    server-addr: localhost:8848
    metadata:
      Preserved.heart.beat.interval: 3 # heartbeat interval. Time unit: second. heartbeat interval 
      Preserved.heart.beat.timeout: 6 # heartbeat pauses. Time unit: second. That is, if the server fails to receive the heartbeat of the client in 6 seconds, the instance registered by the client will be set as unhealthy:
      Preserved.ip.delete.timeout: 9 #ip delete timeout. Time unit: second. That is, if the server fails to receive the heartbeat of the client in 9 seconds, the instance registered by the client will be deleted:

Click and drag to move
When I call a service through URI:, I can call it, but when I use URI LB: / / consumer, I cannot call the service, and an error 503 is reported

The solution is:
Add feign dependency.

<dependencies>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
    <version>3.0.2</version>
</dependency>
<!-- Fegin component fhadmin. Org -- >
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
    <version>3.0.2</version>
</dependency>
<!-- Feign Client for loadBalancing -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-lowww.diuxie.comadbalancer</artifactId>
    <version>3.0.2</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

</dependencies>

Click and drag to move
Guess the reason: Nacos is compatible with feign. Feign integrates ribbon and realizes load balancing by default; Maybe Nacos is not compatible with the ribbon of springcloud gateway.

Recommended Today

OC basis

IOS development interview essential skills chart.png What are objects and what are the objects in OC? An object is an instance of a class; Is an instance created through a class, which is generally called an instance object; Common objects in OC include instance objects, class objects, and metaclass objects; What is a class? What […]