20
votes

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?

5

5 Answers

12
votes

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

11
votes

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.

5
votes

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
1
votes

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
1
votes

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