Zuul Proxy not able to route, resulting in com.netflix.zuul.exception.ZuulException: Forwarding error
Asked Answered
N

6

21

I have simple services as:

transactions-core-service and transactions-api-service.

transactions-api-service invokes transactions-core-service to return a list of transactions. transactions-api-service is enabled with hystrix command.

Both are registered in Eureka server with below services ids:

TRANSACTIONS-API-SERVICE    n/a (1) (1) UP (1) - 192.168.2.12:transactions-api-service:8083
TRANSACTIONS-CORE-SERVICE   n/a (1) (1) UP (1) - 192.168.2.12:transactions-core-service:8087

Below is Zuul server:

@SpringBootApplication

@Controller

@EnableZuulProxy

public class ZuulApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder(ZuulApplication.class).web(true).run(args);
    }
}

Zuul Configurations:

===============================================

info:
  component: Zuul Server

server:
  port: 8765

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true
  health:
    sensitive: false

zuul:
  ignoredServices: "*"
  routes:
    transactions-api-service: 
    path: transactions/accounts/**
    serviceId: transactions-api-service

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

logging:
  level:
    ROOT: INFO
    org.springframework.web: DEBUG

===============================================

When I try to invoke transactions-api-service with url (http://localhost:8765/transactions/accounts/123/transactions/786) I get Zuul Exception:

2016-02-13 11:29:29.050 WARN 4936 --- [nio-8765-exec-1] o.s.c.n.z.filters.post.SendErrorFilter : Error during filtering

com.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:131) ~[spring-cloud-net flix-core-1.1.0.M3.jar:1.1.0.M3] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:76) ~[spring-cloud-netflix- core-1.1.0.M3.jar:1.1.0.M3] ......

If I invoke the transactions-api-service individually (with localhost /accounts/123/transactions/786), it works fine.

Am I missing any configurations on Zuul?

Nitriding answered 13/2, 2016 at 6:29 Comment(1)
I have added in my gateway service application.properties file and it’s workSpar
B
11

You need to change zuul execution timeout by adding this property in application.yml of zuul server:

# Increase the Hystrix timeout to 60s (globally)
hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 60000

Please refer to this thread on netflix issues: https://github.com/spring-cloud/spring-cloud-netflix/issues/321

Baleful answered 6/4, 2016 at 12:57 Comment(1)
You'll still get this error even if this is set.Amoebocyte
Z
10

Faced same issue. In my case, zuul was using service discovery. As a solution, below configuration worked like a charm.

ribbon.ReadTimeout=60000

Reference to the property usage is here.

Zillah answered 4/2, 2019 at 10:44 Comment(1)
This wont work still get errorAmoebocyte
C
4

You have an incorrect indentation. Instead of:

zuul:
  ignoredServices: "*"
  routes:
    transactions-api-service: 
    path: transactions/accounts/**
    serviceId: transactions-api-service

It should be:

zuul:
  ignoredServices: "*"
  routes:
    transactions-api-service: 
      path: transactions/accounts/**
      serviceId: transactions-api-service
Contemporary answered 29/9, 2017 at 10:15 Comment(0)
B
2

you can use this to avoid 500 error

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=1000000

zuul.host.connect-timeout-millis=10000

zuul.host.socket-timeout-millis=1000000

Benitobenjamen answered 23/9, 2020 at 13:27 Comment(1)
works with: host: connect-timeout-millis: 60000 socket-timeout-millis: 60000Pazpaza
T
0

In case if your Zuul gateway uses discovery service for service lookup in that case you can disable the hystrix timeout or increase the hysterix timeout as below :

# Disable Hystrix timeout globally (for all services)
hystrix.command.default.execution.timeout.enabled: false

#To disable timeout foror particular service,
hystrix.command.<serviceName>.execution.timeout.enabled: false

# Increase the Hystrix timeout to 60s (globally)
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000

# Increase the Hystrix timeout to 60s (per service)
hystrix.command.<serviceName>.execution.isolation.thread.timeoutInMilliseconds: 60000
Tricyclic answered 4/3, 2020 at 10:35 Comment(0)
S
0

I was having same issue with zuul server, it got resolved with below property Let's say you have 2 clients clientA and clientB, so for clientA, spring.application.name=clientA and server.port=1111 for clientB spring.application.name=clientB and server.port=2222 in there respective application.propeties files. You want to connect this 2 servers to ZuulServer which is running on port 8087. add below properties in you ZuulServer application.properties file

spring.application.name=gateway-service eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka eureka.client.register-with-eureka=true eureka.client.fetch-registry=true clientA.ribbon.listOfServers=http://localhost:1111
clientB.ribbon.listOfServers=http://localhost:2222

server.port=8087

Note: I am using Eureka Client with my Zuul Server. you can skip that part. Adding this solution in case its helpful for someone.

Statistician answered 18/2, 2022 at 16:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.