These are chat archives for spring-cloud/spring-cloud

9th
Jan 2018
Ziemowit
@Ziemowit
Jan 09 2018 07:42

Hi guys!
After upgrade to Edgware.RELEASE my ZUUL component claims:

com.netflix.zuul.exception.ZuulException: Forwarding error
...
Caused by: org.apache.http.conn.UnsupportedSchemeException: https protocol is not supported

Any ideas what could change between Daltson.SR4 and Edgeware? I have just increased the version of cloud dependencies.

Denis Stepanov
@dstepanov
Jan 09 2018 09:35
Why do I need to change ribbon ReadTimeout values when I have:
spring.cloud.zookeeper:
  enabled: true
  discovery:
    enabled: true
    root: /xyz
  dependency:
    path: /io/mypackage/
    enabled: true
    ribbon:
      enabled: false
... Disabled ribbon
Denis Stepanov
@dstepanov
Jan 09 2018 09:43
Is it a bug when I have ribbon disabled everywhere but still I'm affected by it's configuration?
Dave Syer
@dsyer
Jan 09 2018 09:43
Don't know. You only appear to have disabled the zookeeper bits.
Not sure how that works
Denis Stepanov
@dstepanov
Jan 09 2018 09:44
Ok. Is it possible to disable it at all?
Dave Syer
@dsyer
Jan 09 2018 09:44
For sure you can remove it from the classpath
Normally there is a boolean flag as well
Dave Syer
@dsyer
Jan 09 2018 09:55
Yeah. I don't see one.
I guess you can exclude it.
Or just leave it off the classpath
Denis Stepanov
@dstepanov
Jan 09 2018 09:56
I'm going to try all*.exclude group: 'com.netflix.ribbon'
Would you consider adding a new prop to disable ribbon in the future version?
Dave Syer
@dsyer
Jan 09 2018 09:59
If you can explain why you need it
Not sure what the all* is
Ah, gradle.
Maybe.
I can't help you with Gradle.
Denis Stepanov
@dstepanov
Jan 09 2018 10:00
I'm good with Gradle.
I don't want to use Ribbon or load balancing ;)
Dave Syer
@dsyer
Jan 09 2018 10:00
It should be easy to leave it off the classpath
Denis Stepanov
@dstepanov
Jan 09 2018 10:01
Not in prod ;)
Dave Syer
@dsyer
Jan 09 2018 10:01
Why is "prod" different?
What is "prod"?
Denis Stepanov
@dstepanov
Jan 09 2018 10:02
Because Ribbon comes with very nice 1s read timeout and try to fix that in prod without going deep into Spring sources
Dave Syer
@dsyer
Jan 09 2018 10:02
Yeah, but if you don't want to use it, then don't use it (anywhere).
And there are examples in the main user guide of how to configure it. So hopefully you don't have to go deep into anything really.
Denis Stepanov
@dstepanov
Jan 09 2018 10:08
When I remove Ribbon I get:
Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-netflix-ribbon?
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:214)
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:232)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
    ... 95 common frames omitted
Dave Syer
@dsyer
Jan 09 2018 10:09
So you are using it.
I guess?
AFAIK Feign can be used without Ribbon
Denis Stepanov
@dstepanov
Jan 09 2018 10:10
I don't want to use it
Dave Syer
@dsyer
Jan 09 2018 10:10
Seems like you are though.
We're having to guess really, what it is you want to do.
Denis Stepanov
@dstepanov
Jan 09 2018 10:12
It's nice you think I'm somekind of noob :) I want to use Feign but without any loadbalancing
Dave Syer
@dsyer
Jan 09 2018 10:13
I don't have any opinion on that
Denis Stepanov
@dstepanov
Jan 09 2018 10:13
It's sounds like that, I'm just looking for some help
Dave Syer
@dsyer
Jan 09 2018 10:13
I know you're not a noob. You might need to provide more details.
We only just found out that you want to use Feign
If you have a simple sample app that shows what you need it would help the conversation a lot.
I know it takes time to create such samples.
But it is way more efficient in the long run
AFAIK you can configure a URL (instead of a service id) for Feign.
Haven't tried it recently.
Denis Stepanov
@dstepanov
Jan 09 2018 10:23
Well, first of all I'm trying to solve read timeout exception on prod, then I have found there is Ribbon load-balancing which I thought is disabled, and now it looks like I cannot simply disable it. Problem with Ribbon that it sets default 1s read and connect timeout when Feign default is 60s and 10s. Now when I exclude Ribbon from classpath no Feign Client is provided on context.
I'm using Spring Cloud Zookeeper + FeignClient
Dave Syer
@dsyer
Jan 09 2018 10:26
If you are using ZK for discovery you kind of need Ribbon, right?
Denis Stepanov
@dstepanov
Jan 09 2018 10:27
Looks like there is no way to exclude Ribbon in that case
Dave Syer
@dsyer
Jan 09 2018 10:28
It's kind of pointless.
There isn't another load balancer you can use (yet)
I might be wrong. So we can wait for @spencergibb and @ryanjbaxter to show up in a couple of hours, if you want to check.
Denis Stepanov
@dstepanov
Jan 09 2018 10:30
That would explain why there is no option to exclude Ribbon, that also means there is no way to disable load balancer
Dave Syer
@dsyer
Jan 09 2018 10:32
Indeed. When you started asking, you either didn't say, or I didn't understand, that you were using Feign and Service Discovery.
Denis Stepanov
@dstepanov
Jan 09 2018 11:28

Anyway my solution is:

ribbon:
  ConnectTimeout: 10000
  ReadTimeout: 60000

I would suggest to put it as default and it's the same values as default Feign's

Dave Syer
@dsyer
Jan 09 2018 12:05
That was easy then
The problem with defaults is that everyone has their own opinion.
If you weren't using Feign, it might not be such a good value.
Jagmohan Sharma
@JagmohanSharma
Jan 09 2018 15:50
Hi Team, I am facing one issue with RefreshScope for dynamically initialized beans using BeanDefinitionRegistryPostProcessor. where while setting scope as "refresh", I am not getting any refresh scope registered.
```
beanFactory.getRegisteredScope("refresh")
Dave Syer
@dsyer
Jan 09 2018 15:55
BeanDefinitionRegistryPostProcessor is super early
You probably need to make it happen later
Add an @Order or something
Jagmohan Sharma
@JagmohanSharma
Jan 09 2018 15:58
I tried with setting it order and executed later stage but still did not get refreshs cope registered.
public class PropertyBasedDynamicBeanDefinitionRegistrar implements BeanDefinitionRegistryPostProcessor, BeanFactoryAware {
private ConfigurableBeanFactory beanFactory;
private Class<?> propertyConsumerBean;

public void setPropertyConsumerBean(Class<?> propertyConsumerBean) {
        this.propertyConsumerBean = propertyConsumerBean;
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = (ConfigurableBeanFactory) beanFactory;
    }

private AbstractBeanDefinition prepareConsumerBeanDefinition() {
        BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(propertyConsumerBean);

        if (isRefreshScopeEnabled()) {
            bdb.setScope("refresh");
        }
        return bdb.getBeanDefinition();
    }


    private boolean isRefreshScopeEnabled() {
        return beanFactory.getRegisteredScope("refresh") != null;
    }

    }
Jagmohan Sharma
@JagmohanSharma
Jan 09 2018 18:08
Would it be possible to make such beans refresh scoped?
Dave Syer
@dsyer
Jan 09 2018 18:16
I guess that isRefreshScopeEnabled() is false?
You need a better test for that?