An exception occurred while calling the microservice. When feign is used, the SLB policy is adjusted.

Source: Internet
Author: User

1. Timeout: for example, the order service calls the product-service interface of the commodity service for order-service:

This interface requires a certain amount of response time. This exception occurs when you call it.

Solution: In the order-service configuration file application. yml, set the timeout time:

Timeout Configuration:
The default optons readtimeout value is 60, but because hystrix times out in 1 second by default, response timeout in 1 second is

Server: Port: 8781 # specify the Registry address Eureka: Client: serviceurl: defaultzone: http: // localhost: 8761/Eureka/# service name spring: Application: Name: order-service # custom Server Load balancer policy product-service: Ribbon: nfloadbalancerruleclassname: COM. netflix. loadbalancer. randomrule # modify call timeout 2 sfeign: Client: config: Default: connecttimeout: 2000 readtimeout: 2000

 

 

2. Adjust the load balancing policy when Feign is used

The Difference and choice between ribbon and feign
Select feign during development
1. ribbon is integrated by default.
2. clearer and more convenient ideas
3. Use annotations for configuration and facilitate deployment lockdown.

Therefore:

Feign is configured with the same Server Load balancer as ribbon. Default Round Robin is not configured,

If ribbon is configured, feign is configured, as shown in the configuration in the above file.

An exception occurred while calling the microservice. When feign is used, the SLB policy is adjusted.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.