0

I have build a spring cloud demo with feign and ribbon in it,but the retry function doesn't work.In the same program ,I use RestTemplate too.In this case the retry function works well.Does Feign need extra configuration to use retry?

application.yml

spring:
  cloud:
    loadbalancer:
      retry:
        enabled: true
ribbon:
  MaxAutoRetries: 1
  MaxAutoRetriesNextServer: 2
  OkToRetryOnAllOperations: true

#
capol
  • 1
  • 5
  • What version of Spring Cloud are you using? – Ryan Baxter Feb 15 '17 at 16:03
  • @RyanBaxter My Spring Cloud version is Camden.SR3 – capol Feb 16 '17 at 00:59
  • Can you try Camden.SR5. I don't believe this was in SR3 – Ryan Baxter Feb 17 '17 at 18:04
  • @RyanBaxter Thank you for your patient.I have tried SR5,but the problem is still there.I will put my program in github, can you help me find the problem.Thank you! – capol Feb 18 '17 at 01:39
  • @RyanBaxter https://github.com/zhqh9016/SpringCloudDemo.git – capol Feb 18 '17 at 01:47
  • Your project called `CloudRibbon` is using SR3 please use SR5. I have been fixing some bugs when it comes to Feign and retrying failed requests over the past couple days. If you use `Camden.BUILD-SNAPSHOT` or `Dalston.BUILD-SNAPSHOT`. You will have the latest and greatest code. However `SR5` should work. With `SR5` you will not have to do any configuration of `Retryer` either, we now using Spring Retry. http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#retrying-failed-requests – Ryan Baxter Feb 20 '17 at 20:05
  • @RyanBaxter In local side I have tried Camden.SR5, it truly doesn't work.I think there must be something wrong with my config file in my project. Now I have change the version of spring cloud to Camden.SR5 in github.I get so little message associate with my problem from stackoverflow and google. Please give me some suggestion about my config.Thank you. – capol Feb 21 '17 at 02:24
  • Can you please put the exact steps you are using to reproduce the problem in the README of the repo so I can try and reproduce it locally? – Ryan Baxter Feb 21 '17 at 14:49
  • @RyanBaxter I have add some description of the problem in README.md – capol Feb 21 '17 at 15:07
  • I am debugging the code in `FeignLoadBalancer` and I see the retry working fine. – Ryan Baxter Feb 21 '17 at 16:16
  • @RyanBaxter did you get wrong message in browser? – capol Feb 21 '17 at 16:17
  • @RyanBaxter Everytime I tried to stop a instance I will get a wrong access. – capol Feb 21 '17 at 16:20
  • I dont know what you mean by "wrong message". If a request fails to one instance of the service (in this case because the service is down) it will select another instance and try the request again. – Ryan Baxter Feb 21 '17 at 16:40
  • @RyanBaxter Yes, I expected if a request fails to one instance of the service it will select another instance,but in fact ,feign didn't do it for me like this in my program. Now ,if feign hit a crashed instance ,I will get the Whitelabel Error Page and show me this "There was an unexpected error (type=Internal Server Error, status=500). FeignService#hello() timed-out and no fallback available." .Several of my colleagues have gone through the same situation. – capol Feb 22 '17 at 01:53
  • I am not sure what else to try. I used your repo and followed the steps in the README and I see it retrying failed request perfectly fine. – Ryan Baxter Feb 22 '17 at 15:38
  • @RyanBaxter You have spent so much time in my question, thank you.I will debug FeignLoadBalancer tomorrow. – capol Feb 22 '17 at 15:43
  • @RyanBaxter Today I have debuged my code ,and I found retry works well too. I read the wrong message I mentioned in eariler comment again and I found my problem was caused by Hystrix .I forgot that when feign was included in program the hystrix would work automatically .By default hystrix set timeout by 1 second but retry need longger. Why spring didn't set a larger value by default for hystrix when works with feign. – capol Feb 23 '17 at 12:45
  • OK makes more sense. We are thinking about turning off the Hystrix support for Feign by default in the next release. https://github.com/spring-cloud/spring-cloud-netflix/issues/1277 – Ryan Baxter Feb 23 '17 at 18:21

0 Answers0