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

21st
May 2018
vikrantch-hk
@vikrantch-hk
May 21 2018 08:23

@marcosbarbero I am using eureka in aws, things are working properly but I get below logs

java.lang.StringIndexOutOfBoundsException: String index out of range: -4
        at java.lang.String.substring(String.java:1967) ~[na:1.8.0_152]
        at com.netflix.eureka.aws.EIPManager.getEIPsFromServiceUrls(EIPManager.java:360) ~[eureka-core-1.9.0.jar!/:1.9.0]
        at com.netflix.eureka.aws.EIPManager.getEIPsForZoneFromConfig(EIPManager.java:335) ~[eureka-core-1.9.0.jar!/:1.9.0]

so I found out that by default spring uses EIP , but in our case we have static IPs and aren't using EIP . Is there a way to disable EIP setting in spring eureka

Marcos Barbero
@marcosbarbero
May 21 2018 08:44
@vikrantch-hk did you configure the AWS profile as suggested in the docs?
vikrantch-hk
@vikrantch-hk
May 21 2018 09:51
yes , please have a look
eureka.environment: prod
eureka.server.registry-sync-retry-wait-ms: 500
eureka.server.a-sgcache-expiry-timeout-ms: 60000
eureka.server.eviction-interval-timer-in-ms: 3000
eureka.server.peer-eureka-nodes-update-interval-ms: 3000
eureka.server.renewal-threshold-update-interval-ms: 3000
aws.region.static: ap-south-1
eureka.isAws: true
eureka.datacenter: cloud
eureka.instance.metadataMap.zone: ap-south-1
eureka.client.region: ap-south-1
eureka.client.prefer-same-zone-eureka: true
eureka.client.availability-zones.ap-south-1: 'ap-south-1a,ap-south-1b'
eureka.client.serviceUrl.ap-south-1a: http://10.0.10.97:8080/eureka/
eureka.client.serviceUrl.ap-south-1b: http://10.0.20.97:8080/eureka/
eureka server and clients are working fine only thing is EIP manager error logs
Marcos Barbero
@marcosbarbero
May 21 2018 10:13
Did you see this spring-cloud/spring-cloud-netflix#188
?
vikrantch-hk
@vikrantch-hk
May 21 2018 10:16
yes I am using this code
@Bean
    @Profile("prod")
    public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
        EurekaInstanceConfigBean b = new EurekaInstanceConfigBean(inetUtils);
        AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
        b.setDataCenterInfo(info);
        return b;
    }
but there is no clear solution mentioned
Marcos Barbero
@marcosbarbero
May 21 2018 10:26
I see, right now I’m only with mobile connection. Once I reach my machine I can try to find out what else you can do.
However, do you have your code in a public repo? It might help
vikrantch-hk
@vikrantch-hk
May 21 2018 10:28
no it's not I can share application yaml and bean config if needed
Marcos Barbero
@marcosbarbero
May 21 2018 10:29
Please do
vikrantch-hk
@vikrantch-hk
May 21 2018 10:58
application yaml
eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    serviceUrl:
      defaultZone: http://localhost:8080/eureka/
  instance:
    leaseRenewalIntervalInSeconds: 20
    leaseExpirationDurationInSeconds: 60
    preferIpAddress: true
server.port: 8080
third:
  party:
    api:
      access:
        user:
          name: api
        password: api
hystrix:
  command:
    api:
      execution:
        timeout:
          enabled: false
        isolation:
          thread:
            timeoutInMilliseconds: 60000
    hkSecurity:
      execution:
        timeout:
          enabled: false
        isolation:
          thread:
            timeoutInMilliseconds: 60000
eureka.environment: prod
eureka.server.registry-sync-retry-wait-ms: 500
eureka.server.a-sgcache-expiry-timeout-ms: 60000
eureka.server.eviction-interval-timer-in-ms: 3000
eureka.server.peer-eureka-nodes-update-interval-ms: 3000
eureka.server.renewal-threshold-update-interval-ms: 3000
aws.region.static: ap-south-1
eureka.isAws: true
eureka.datacenter: cloud
eureka.instance.metadataMap.zone: ap-south-1
eureka.client.region: ap-south-1
eureka.client.prefer-same-zone-eureka: true
eureka.client.availability-zones.ap-south-1: 'ap-south-1a,ap-south-1b'
eureka.client.serviceUrl.ap-south-1a: http://10.0.10.97:8080/eureka/
eureka.client.serviceUrl.ap-south-1b: http://10.0.20.97:8080/eureka/
bean for aws config
@Bean
    @Profile("prod")
    public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
        EurekaInstanceConfigBean b = new EurekaInstanceConfigBean(inetUtils);
        AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
        b.setDataCenterInfo(info);
        return b;
    }
Marcos Barbero
@marcosbarbero
May 21 2018 11:23
How are you deploying it? Any jvm arguments?
vikrantch-hk
@vikrantch-hk
May 21 2018 11:31
no
we are running jar without any jvm arguments
it seems to be exactly same issue as Netflix/eureka#818
Marcos Barbero
@marcosbarbero
May 21 2018 11:37
How are you enabling this profile? I mean the prod profile for the bean above?
vikrantch-hk
@vikrantch-hk
May 21 2018 11:40
this is application-prod.yml below is application.yml
spring:
  application:
    name: gateway-service
  profiles:
    active: prod
  cache:
    cache-names: appConfig
    caffeine:
      spec: expireAfterAccess=180s
  cloud:
    refresh:
      enabled: false
eureka.server.enable-self-preservation: true
management:
  endpoint:
    health:
      enabled: true
ribbon:
  ConnectTimeout:  15000
  ReadTimeout:  15000
zuul:
  host:
    socket-timeout-millis: 60000
  retryable: true
  sensitiveHeaders:
  routes:
    api:
      path: /api/**
      service-id: api
      strip-prefix: false
    hkSecurity:
      path: /hkSecurity/**
      service-id: hkSecurity
      strip-prefix: true
    feed:
      path: /feed/**
      service-id: api
      strip-prefix: false
feign.hystrix.enabled: true
hystrix.command.default.fallback.enabled: true
hystrix.command.default.circuitBreaker.enabled: true
logging:
  file: APIGateway.log
  level:
    root: INFO
Marcos Barbero
@marcosbarbero
May 21 2018 11:44
It doesn’t work that way. You need to set the active profile either by jvm args or in the application.yml (ok, you have some more options), the way you are doing the prod profile will never be picked up
vikrantch-hk
@vikrantch-hk
May 21 2018 11:50
@marcosbarbero i am setting active profile as prod in application yaml
as mentioned above
Marcos Barbero
@marcosbarbero
May 21 2018 11:52
Isn’t it the application-prod.yml?
vikrantch-hk
@vikrantch-hk
May 21 2018 11:54
nope this is application.yml application-prod.yml is on top of it initially I pasted prod yaml only as only it has aws netflix config
Marcos Barbero
@marcosbarbero
May 21 2018 11:57
Ah ok, sorry for the misunderstanding
Seems to be related to the issue that you shared few ago. Did you try to set this property? eureka.server.binding-strategy
vikrantch-hk
@vikrantch-hk
May 21 2018 12:02
no I talked to my Devops team
and they are saying we are not using either of these binding strategies
and if you will read issue description also @robertnosburn has suggested to add a no-op binder
vikrantch-hk
@vikrantch-hk
May 21 2018 12:07
I tried setting eureka.eipBindRebindRetries: 0 but it's also not working
CH4:D
@chad_d_stud_twitter
May 21 2018 12:13
i keep getting intermittent disconnections from my hystrix systems
in spite of the fact that they’re all on my local machine
i tried spawning a second instnce but still gets an occasional error
Sushant
@bsushant-athena
May 21 2018 12:48
@marcosbarbero eureka.maxRetries currently we kept to 30 ; but if the server is down and the retry count reaches to 30 then the clients does not re-register that is why we need to specify to more higher value so that it keeps on retrying!
Marcos Barbero
@marcosbarbero
May 21 2018 13:43
@bsushant-athena are you sure that eureka.maxRetries is a valid config property?
@vikrantch-hk unfortunately I don’t have an AWS account to try out right now.
If I find something else I’ll get back to you
KaijuDeluxe
@KaijuDeluxe
May 21 2018 15:14
hi i am looking for a java framework to generate UI is there something else than vaadin? i thnk vaadin is cunfusing me
Sergey Kryvets
@sergeome
May 21 2018 22:39

Hello, can somebody help with the following: spring doesn't want to pick up native profile. Every time during compilation it throws an error, saying "You need to configure a uri for the git repository". My application.properties file looks like this:

server.port=8888
spring.profiles.active=native

Other people experience the same problem - https://stackoverflow.com/a/30933126/2009145
Could you please suggest how to make it work with native profile? Thank you a lot in advance!
P.s. my github repo

Marcos Barbero
@marcosbarbero
May 21 2018 22:51
There are few misconfiguration in your project.
First, you don’t have a bootstrap.yml(properties) where you have to set this uri that you mentioned.
And then you also don’t have any native profile in the app
Sergey Kryvets
@sergeome
May 21 2018 22:54
@marcosbarbero, thank you a lot for taking your time and looking into this problem

where you have to set this uri that you

I thought if I set spring.profiles.active=native I don’t need to set uri. Is that wrong?

Marcos Barbero
@marcosbarbero
May 21 2018 22:59
Oops, my mistake.
Try to set this property in a bootstrap.properties instead
I mean the profile active
Sergey Kryvets
@sergeome
May 21 2018 23:05

Just tried, the same error…
In the one of the stackoverflow threads there is workaround:

Finally the way it worked for me on the mac was to pass the active profile to the jar file, like this
java -jar config-server.jar --spring.profiles.active=native
I still don't know why it behaves differently in Mac OS.

Seems like it’s a Mac issue (I’m Mac user). Maybe you have any thoughts on that?
Again, thank you very much for helping with this.

I hoped to make it work without passing cmd param to jar, since this is a workaround and probably not the expected way it should behave.
Spencer Gibb
@spencergibb
May 21 2018 23:11
@sergeome I just ran your app with no problems, serves config just fine
Sergey Kryvets
@sergeome
May 21 2018 23:12
@spencergibb, thanks a lot for your help! Did you run this on a Mac?
Spencer Gibb
@spencergibb
May 21 2018 23:13
no
Marcos Barbero
@marcosbarbero
May 21 2018 23:14
I can try it in a Mac OS, however in 1 hour from now 😄
Sergey Kryvets
@sergeome
May 21 2018 23:15
Thank you @marcosbarbero, sounds good! :thumbsup:
Marcos Barbero
@marcosbarbero
May 21 2018 23:39
@sergeome I just tried it
2018-05-21 20:38:24.733  INFO 1871 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8888 (http) with context path ''
2018-05-21 20:38:24.737  INFO 1871 --- [           main] c.s.SpringConfigServerApplication        : Started SpringConfigServerApplication in 4.142 seconds (JVM running for 4.618)
everything seems to be ok, I just did
./gradlew clean build && java -jar build/libs/spring-config-server-0.0.1-SNAPSHOT.jar
Sergey Kryvets
@sergeome
May 21 2018 23:43
hm, that’s interesting. I’m doing
./gradlew clean && ./gradlew bootRun
2018-05-21 18:40:25.981  INFO 3924 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-05-21 18:40:25.981  INFO 3924 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1007 ms
2018-05-21 18:40:26.528 ERROR 3924 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]: Factory method 'healthEndpoint' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configServerHealthIndicator' defined in class path resource [org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.class]: Unsatisfied dependency expressed through method 'configServerHealthIndicator' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.config.server.config.CompositeConfiguration': Unsatisfied dependency expressed through method 'setEnvironmentRepos' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEnvironmentRepository' defined in class path resource [org/springframework/cloud/config/server/config/DefaultRepositoryConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: You need to configure a uri for the git repository
2018-05-21 18:40:26.546  INFO 3924 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
Marcos Barbero
@marcosbarbero
May 21 2018 23:44
I just did the same, also worked
Sergey Kryvets
@sergeome
May 21 2018 23:45
Thanks a lot for your help!
Something wrong with my machine.
Really sorry for that. :-(
Marcos Barbero
@marcosbarbero
May 21 2018 23:45
it happens, don't worry