Why does using ribbonReadTimeout don't break long request with Netflix Ribbon?












1














We are using Spring Boot 2.0.0.RELEASE with spring-cloud-starter-netflix-ribbon for our micro services. I set ribbon.readTimeout=1000 for slow requests and check it with our micro service setting breakpoint inside @GetMapping method without sending a response. In my test I have been waiting for 10 minutes and did not get any exception. It seems like there is no readTimeout at all.



Service configuration



ribbon:
ReadTimeout: 1000

my-service:
ribbon:
eureka:
enabled: false
listOfServers: localhost:8080
ReadTimeout: 1000
ConnectTimeout: 1000


The only way a can make it work is ribbon.restclient.enabled=true. But this client is deprecated and I don't wont to use it.










share|improve this question



























    1














    We are using Spring Boot 2.0.0.RELEASE with spring-cloud-starter-netflix-ribbon for our micro services. I set ribbon.readTimeout=1000 for slow requests and check it with our micro service setting breakpoint inside @GetMapping method without sending a response. In my test I have been waiting for 10 minutes and did not get any exception. It seems like there is no readTimeout at all.



    Service configuration



    ribbon:
    ReadTimeout: 1000

    my-service:
    ribbon:
    eureka:
    enabled: false
    listOfServers: localhost:8080
    ReadTimeout: 1000
    ConnectTimeout: 1000


    The only way a can make it work is ribbon.restclient.enabled=true. But this client is deprecated and I don't wont to use it.










    share|improve this question

























      1












      1








      1







      We are using Spring Boot 2.0.0.RELEASE with spring-cloud-starter-netflix-ribbon for our micro services. I set ribbon.readTimeout=1000 for slow requests and check it with our micro service setting breakpoint inside @GetMapping method without sending a response. In my test I have been waiting for 10 minutes and did not get any exception. It seems like there is no readTimeout at all.



      Service configuration



      ribbon:
      ReadTimeout: 1000

      my-service:
      ribbon:
      eureka:
      enabled: false
      listOfServers: localhost:8080
      ReadTimeout: 1000
      ConnectTimeout: 1000


      The only way a can make it work is ribbon.restclient.enabled=true. But this client is deprecated and I don't wont to use it.










      share|improve this question













      We are using Spring Boot 2.0.0.RELEASE with spring-cloud-starter-netflix-ribbon for our micro services. I set ribbon.readTimeout=1000 for slow requests and check it with our micro service setting breakpoint inside @GetMapping method without sending a response. In my test I have been waiting for 10 minutes and did not get any exception. It seems like there is no readTimeout at all.



      Service configuration



      ribbon:
      ReadTimeout: 1000

      my-service:
      ribbon:
      eureka:
      enabled: false
      listOfServers: localhost:8080
      ReadTimeout: 1000
      ConnectTimeout: 1000


      The only way a can make it work is ribbon.restclient.enabled=true. But this client is deprecated and I don't wont to use it.







      spring-boot spring-cloud spring-cloud-netflix netflix-ribbon






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 7:06









      Alexey Saltanov

      82




      82
























          3 Answers
          3






          active

          oldest

          votes


















          1














          Not all the ribbon properties are supported by spring-cloud-netflix while being used with a Spring RestTemplate. There are some ribbon properties that work, as described in the docs, but ReadTimeout is not one of them. So it does not work, but it's by desing (as per the response to this issue). However, if you are using Spring's RestTemplate, you can set it there directly, like so:



          @LoadBalanced
          @Bean
          RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
          return restTemplateBuilder
          .setReadTimeout(2000)
          .build();
          }





          share|improve this answer























          • Thank you very much indeed. I've set request timeout for RestTemplate and now it works fine.
            – Alexey Saltanov
            Nov 21 at 11:18










          • @AlexeySaltanov I'm happy it was helpful. As it has solved your problem, could you please mark this answer as accepted and give it a +1?
            – OlgaMaciaszek
            Nov 21 at 11:24



















          0














          We find this:



          serviceA.ribbon.ReadTimeout=8000


          work well with spring boot 2.1.0.RELEASE using spring cloud Finchley.SR2 and



          <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
          </dependency>

          <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-openfeign</artifactId>
          </dependency>


          However, we use ribbon via feign, in a client as so:



          @FeignClient(value = "serviceA")
          public interface ServiceAClient {

          @GetMapping(value = "/test")
          String getTest();
          }


          We then use a wiremock test to introduce a fixed delay above the read timeout to verify it is working fine.






          share|improve this answer





























            0














            I think you need to configure Hystrix timeouts. Take a look at this part of the documentation : http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html#_hystrix_timeouts_and_ribbon_clients
            It could be something like that :



            hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 1100
            ribbon:
            ConnectTimeout: 1000
            ReadTimeout: 1000





            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387857%2fwhy-does-using-ribbonreadtimeout-dont-break-long-request-with-netflix-ribbon%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              Not all the ribbon properties are supported by spring-cloud-netflix while being used with a Spring RestTemplate. There are some ribbon properties that work, as described in the docs, but ReadTimeout is not one of them. So it does not work, but it's by desing (as per the response to this issue). However, if you are using Spring's RestTemplate, you can set it there directly, like so:



              @LoadBalanced
              @Bean
              RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
              return restTemplateBuilder
              .setReadTimeout(2000)
              .build();
              }





              share|improve this answer























              • Thank you very much indeed. I've set request timeout for RestTemplate and now it works fine.
                – Alexey Saltanov
                Nov 21 at 11:18










              • @AlexeySaltanov I'm happy it was helpful. As it has solved your problem, could you please mark this answer as accepted and give it a +1?
                – OlgaMaciaszek
                Nov 21 at 11:24
















              1














              Not all the ribbon properties are supported by spring-cloud-netflix while being used with a Spring RestTemplate. There are some ribbon properties that work, as described in the docs, but ReadTimeout is not one of them. So it does not work, but it's by desing (as per the response to this issue). However, if you are using Spring's RestTemplate, you can set it there directly, like so:



              @LoadBalanced
              @Bean
              RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
              return restTemplateBuilder
              .setReadTimeout(2000)
              .build();
              }





              share|improve this answer























              • Thank you very much indeed. I've set request timeout for RestTemplate and now it works fine.
                – Alexey Saltanov
                Nov 21 at 11:18










              • @AlexeySaltanov I'm happy it was helpful. As it has solved your problem, could you please mark this answer as accepted and give it a +1?
                – OlgaMaciaszek
                Nov 21 at 11:24














              1












              1








              1






              Not all the ribbon properties are supported by spring-cloud-netflix while being used with a Spring RestTemplate. There are some ribbon properties that work, as described in the docs, but ReadTimeout is not one of them. So it does not work, but it's by desing (as per the response to this issue). However, if you are using Spring's RestTemplate, you can set it there directly, like so:



              @LoadBalanced
              @Bean
              RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
              return restTemplateBuilder
              .setReadTimeout(2000)
              .build();
              }





              share|improve this answer














              Not all the ribbon properties are supported by spring-cloud-netflix while being used with a Spring RestTemplate. There are some ribbon properties that work, as described in the docs, but ReadTimeout is not one of them. So it does not work, but it's by desing (as per the response to this issue). However, if you are using Spring's RestTemplate, you can set it there directly, like so:



              @LoadBalanced
              @Bean
              RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
              return restTemplateBuilder
              .setReadTimeout(2000)
              .build();
              }






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 20 at 17:19

























              answered Nov 20 at 17:01









              OlgaMaciaszek

              1,4301419




              1,4301419












              • Thank you very much indeed. I've set request timeout for RestTemplate and now it works fine.
                – Alexey Saltanov
                Nov 21 at 11:18










              • @AlexeySaltanov I'm happy it was helpful. As it has solved your problem, could you please mark this answer as accepted and give it a +1?
                – OlgaMaciaszek
                Nov 21 at 11:24


















              • Thank you very much indeed. I've set request timeout for RestTemplate and now it works fine.
                – Alexey Saltanov
                Nov 21 at 11:18










              • @AlexeySaltanov I'm happy it was helpful. As it has solved your problem, could you please mark this answer as accepted and give it a +1?
                – OlgaMaciaszek
                Nov 21 at 11:24
















              Thank you very much indeed. I've set request timeout for RestTemplate and now it works fine.
              – Alexey Saltanov
              Nov 21 at 11:18




              Thank you very much indeed. I've set request timeout for RestTemplate and now it works fine.
              – Alexey Saltanov
              Nov 21 at 11:18












              @AlexeySaltanov I'm happy it was helpful. As it has solved your problem, could you please mark this answer as accepted and give it a +1?
              – OlgaMaciaszek
              Nov 21 at 11:24




              @AlexeySaltanov I'm happy it was helpful. As it has solved your problem, could you please mark this answer as accepted and give it a +1?
              – OlgaMaciaszek
              Nov 21 at 11:24













              0














              We find this:



              serviceA.ribbon.ReadTimeout=8000


              work well with spring boot 2.1.0.RELEASE using spring cloud Finchley.SR2 and



              <dependency>
              <groupId>org.springframework.cloud</groupId>
              <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
              </dependency>

              <dependency>
              <groupId>org.springframework.cloud</groupId>
              <artifactId>spring-cloud-starter-openfeign</artifactId>
              </dependency>


              However, we use ribbon via feign, in a client as so:



              @FeignClient(value = "serviceA")
              public interface ServiceAClient {

              @GetMapping(value = "/test")
              String getTest();
              }


              We then use a wiremock test to introduce a fixed delay above the read timeout to verify it is working fine.






              share|improve this answer


























                0














                We find this:



                serviceA.ribbon.ReadTimeout=8000


                work well with spring boot 2.1.0.RELEASE using spring cloud Finchley.SR2 and



                <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
                </dependency>

                <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-openfeign</artifactId>
                </dependency>


                However, we use ribbon via feign, in a client as so:



                @FeignClient(value = "serviceA")
                public interface ServiceAClient {

                @GetMapping(value = "/test")
                String getTest();
                }


                We then use a wiremock test to introduce a fixed delay above the read timeout to verify it is working fine.






                share|improve this answer
























                  0












                  0








                  0






                  We find this:



                  serviceA.ribbon.ReadTimeout=8000


                  work well with spring boot 2.1.0.RELEASE using spring cloud Finchley.SR2 and



                  <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
                  </dependency>

                  <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-starter-openfeign</artifactId>
                  </dependency>


                  However, we use ribbon via feign, in a client as so:



                  @FeignClient(value = "serviceA")
                  public interface ServiceAClient {

                  @GetMapping(value = "/test")
                  String getTest();
                  }


                  We then use a wiremock test to introduce a fixed delay above the read timeout to verify it is working fine.






                  share|improve this answer












                  We find this:



                  serviceA.ribbon.ReadTimeout=8000


                  work well with spring boot 2.1.0.RELEASE using spring cloud Finchley.SR2 and



                  <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
                  </dependency>

                  <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-starter-openfeign</artifactId>
                  </dependency>


                  However, we use ribbon via feign, in a client as so:



                  @FeignClient(value = "serviceA")
                  public interface ServiceAClient {

                  @GetMapping(value = "/test")
                  String getTest();
                  }


                  We then use a wiremock test to introduce a fixed delay above the read timeout to verify it is working fine.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 20 at 17:10









                  David Goate

                  1,05521533




                  1,05521533























                      0














                      I think you need to configure Hystrix timeouts. Take a look at this part of the documentation : http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html#_hystrix_timeouts_and_ribbon_clients
                      It could be something like that :



                      hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 1100
                      ribbon:
                      ConnectTimeout: 1000
                      ReadTimeout: 1000





                      share|improve this answer


























                        0














                        I think you need to configure Hystrix timeouts. Take a look at this part of the documentation : http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html#_hystrix_timeouts_and_ribbon_clients
                        It could be something like that :



                        hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 1100
                        ribbon:
                        ConnectTimeout: 1000
                        ReadTimeout: 1000





                        share|improve this answer
























                          0












                          0








                          0






                          I think you need to configure Hystrix timeouts. Take a look at this part of the documentation : http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html#_hystrix_timeouts_and_ribbon_clients
                          It could be something like that :



                          hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 1100
                          ribbon:
                          ConnectTimeout: 1000
                          ReadTimeout: 1000





                          share|improve this answer












                          I think you need to configure Hystrix timeouts. Take a look at this part of the documentation : http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html#_hystrix_timeouts_and_ribbon_clients
                          It could be something like that :



                          hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 1100
                          ribbon:
                          ConnectTimeout: 1000
                          ReadTimeout: 1000






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 20 at 17:10









                          veben

                          1,0712921




                          1,0712921






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387857%2fwhy-does-using-ribbonreadtimeout-dont-break-long-request-with-netflix-ribbon%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                              Alcedinidae

                              RAC Tourist Trophy