Error: getaddrinfo EAI_AGAIN restaurant-service, Cloud Gateway 404 error

133 Views Asked by At

I have made a microservices using spring boot. I am using Eureka,hystrix,and cloud gateway

My Cloud Gateway application.yml is:-

    ```spring:
       application:
       name: GATEWAY-SERVICE
       cloud:
       gateway:
       routes:
       - id: order-service
        uri: lb://ORDER-SERVICE
        predicates:
      - Path=/order/**
       filters:
       - name: CircuitBreaker
        args:
          name: order-service
          fallbackuri: forward:/orderFallBack
      - id: res-service
    uri: lb://RESTAURANT-SERVICE
    predicates:
      - Path=/res/**
    filters:
      - name: CircuitBreaker
        args:
          name: res-service
          fallbackuri: forward:/restaurantFallBack
          
   eureka:
   client:
  fetch-registry: true
  register-with-eureka: true
  serviceUrl:
   defaultZone: http://localhost:8761/eureka/
  instance:
  preferIpAddress: true      
 server:
 port: 8988

management:
 endpoints:
  web:
   exposure:
    include: hystrix.stream
    
 hystrix:
  command:
    fallbackcmd:
      execution:
     isolation:
      thread:
        timeoutInMilliseconds: 5000  ```

My Eureka application.yml is this:

    ```server:
       port: 8761

      eureka:
      client:   
     register-with-eureka: false
      fetch-registry: false```

My Restauarant service's Application.properties....just notice that I am not using Application.yml

      ```server.port:8086

       spring.zipkin.base-url:http://localhost:9411/
         spring.application.name:RESTAURANT-SERVICE
           spring.datasource.url:jdbc:mysql://127.0.1.1:3307/SpringBoot201
            spring.datasource.username=root
         spring.datasource.password=
            spring.jpa.hibernate.ddl-auto=update
                eureka.client.fetch-registry: true
          eureka.client.register-with-eureka: true
            eureka.client.serviceUrl.defaultZone: http://localhost:8761/eureka/
              eureka.client.serviceUrl.instance.preferIpAddress: true```

My orderManagement Service Application.properties is this:-

            ```server.port:8087

                  spring.zipkin.base-url:http://localhost:9411/
                      spring.application.name:ORDER-SERVICE
                   spring.datasource.url:jdbc:mysql://127.0.1.1:3307/SpringBoot201
                  spring.datasource.username=root
                  spring.datasource.password=
                   spring.jpa.hibernate.ddl-auto=update
                 eureka.client.fetch-registry: true
                eureka.client.register-with-eureka: true
            eureka.client.serviceUrl.defaultZone: http://localhost:8761/eureka/
           eureka.client.serviceUrl.instance.preferIpAddress: true```

when I am sending request either for ORDER-SERVICE or for RESTAURANT-SERVICE...I am getting this error in postman PostMan Showing Error

My Eureka is showing this Eureka is working fine

But when I am going to Cloud Gateway, it is showing this Cloud Gateway 404 error

1

There are 1 best solutions below

0
Pragya Kumari On

There is no error in application.yml or application.properties. Actually in the controller part of ORDER-SERVICE and Controller part of RESTAURANT-SERVICE, I needed to add @RequestMapping("/order") @RequestMapping("/res") as in the application.yml it is mentioned

  • Path=/order/** -Path=/res/** means it should start with these