javaspring-bootmicroservicesnetflix-eurekanetflix-zuul

Zuul unable to route to application registered in eureka server


I am developing a Microservice were I am trying to use the Zuul proxy to route through the services. But for some reason Zuul unable to route to the app registered in eureka. I have tried increasing hystrix and Zuul timeout but nothing working

Exception Thrown

com.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:198) ~[spring-cloud-netflix-zuul-2.2.10.RELEASE.jar:2.2.10.RELEASE]

Zuul application.yml

server:
  port: 8082

spring:
  application:
    name: gateway
eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    serviceUrl:
      defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
  instance:
    hostname: localhost

ribbon:
  eureka:
    enabled: true

zuul:
  ignoredServices: "*"
  host:
    connect-timeout-millis: 5000000
    socket-timeout-millis: 5000000
  prefix: /api
  routes:
    game:
      path: /game/**
      serviceId: game
    trend:
      path: /trend/**
      serviceId: trend

Here I have two Microservices called "game" and "trend" both are registered in eureka service, but not able to navigate to applications through Zuul proxy.

enter image description here


Solution

  • After Some research I found that Ribbon, Zuul are in maintenance mode and we won't get any new version and spring also came up with alternative for Ribbon, Zuul etc. Please refer this link for spring alternative for load balancing, proxy server etc

    And for this issue I used spring cloud gateway instead of Zuul which is the alternative provided by spring

    Required Dependency

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-gateway</artifactId>
                <version>3.1.0</version>
            </dependency>
    

    Now the application yml of proxy server looks like

    server:
      port: 8082
    
    spring:
      application:
        name: gateway
      cloud:
        gateway:
          discovery:
            locator:
              enabled: true
              lower-case-service-id: true
          routes:
            - id: game
              uri: lb://game
              predicates:
                - Path=/game/**
            - id: trend
              uri: lb://trend
              predicates:
                - Path=/trend/**
    
    eureka:
      client:
        serviceURL:
          defaultZone: http://localhost:8761/eureka