spring-cloud-netflix icon indicating copy to clipboard operation
spring-cloud-netflix copied to clipboard

Eureka Client heartbeat failure after switching to Brixton.RC1

Open robin-maxxton opened this issue 10 years ago • 14 comments

I'm experiencing an issue with the heartbeat mechanism from the Eureka Client. Ever since I switched to Brixton.RC1 the following events occur after a successful startup Before this I was on the Angel.SR6 release train

First the the client registers itself to the Eureka server in a normal manner

2016-04-05 13:32:40.057  INFO 12344 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_FEIGN-PROTOTYPE/local:feign-prototype:0: registering service...
2016-04-05 13:32:40.098  INFO 12344 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_FEIGN-PROTOTYPE/local:feign-prototype:0 - registration status: 204

It's then also visible on the dashboard of the Eureka server. But at the first heartbeat it fails and throws the following error(s):

2016-04-05 13:33:10.034 ERROR 12344 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error

javax.ws.rs.WebApplicationException: null
    at com.netflix.discovery.provider.DiscoveryJerseyProvider.readFrom(DiscoveryJerseyProvider.java:110)
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:634)
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:586)
    at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.sendHeartBeat(AbstractJerseyEurekaHttpClient.java:105)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:119)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:823)
    at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1379)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

2016-04-05 13:33:10.036  WARN 12344 --- [tbeatExecutor-0] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failure
2016-04-05 13:33:10.042 ERROR 12344 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error

javax.ws.rs.WebApplicationException: null
    at com.netflix.discovery.provider.DiscoveryJerseyProvider.readFrom(DiscoveryJerseyProvider.java:110)
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:634)
    at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:586)
    at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.sendHeartBeat(AbstractJerseyEurekaHttpClient.java:105)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118)
    at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:119)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:823)
    at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1379)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

2016-04-05 13:33:10.043  WARN 12344 --- [tbeatExecutor-0] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failure
2016-04-05 13:33:10.045 ERROR 12344 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_FEIGN-PROTOTYPE/local:feign-prototype:0 - was unable to send heartbeat!

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
    at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$3.execute(EurekaHttpClientDecorator.java:92)
    at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.sendHeartBeat(EurekaHttpClientDecorator.java:89)
    at com.netflix.discovery.DiscoveryClient.renew(DiscoveryClient.java:823)
    at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1379)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

After about three failed heartbeat the client gets discarded from the eureka server. That seems like normal behavior to me (3 failed heartbeats, 30 sec each, means that the service has been shut down)

I can't seem to find the thing that is causing this. My configuration looks like this:

eureka:
  client:
    serviceUrl:
      defaultZone: http://127.0.0.1:8002/eureka/
  instance:
     preferIpAddress: true

Did some of the required configuration change or has there been a big change in the Eureka client? Thanks in advance

Robin

robin-maxxton avatar Apr 05 '16 11:04 robin-maxxton

The configuration hasn't changed much, but eureka client has been upgraded. Do you have a sample that recreates the problem?

spencergibb avatar Apr 06 '16 04:04 spencergibb

No problem This sample should recreate the problem https://github.com/robin-maxxton/heartbeat-sample

robin-maxxton avatar Apr 06 '16 07:04 robin-maxxton

I don't see any errors while running your project against a local eureka. Must be something to do with your eureka or something else locally.

spencergibb avatar Apr 06 '16 18:04 spencergibb

Well it's good to know the problem does not lie in the Eureka client. I guess the problem than has something to do with my Eureka having outdated dependencies. I thought I updated them, but I guess something went wrong there.

Let me check if this is indeed the case. I'll let you know what my findings are.

robin-maxxton avatar Apr 06 '16 18:04 robin-maxxton

I think I found the issue. When updating the dependencies of my Eureka server to RC1 I forgot to change the mavenBom from org.springframework.cloud:spring-cloud-starter-parent to org.springframework.cloud:spring-cloud-dependencies That solves it. Thanks for the help

robin-maxxton avatar Apr 07 '16 07:04 robin-maxxton

So just for clarification. Eureka 1.1 that was used before is not compatible with Eureka 1.4 that is now being used?

kristofferpeterhansel avatar Apr 12 '16 11:04 kristofferpeterhansel

I started to get these errors today... No related change that I can think of.

magnusheino avatar Apr 12 '16 14:04 magnusheino

I got the error on the eureka server, which also was a eureka client. I added

registerWithEureka: false fetchRegistry: false

and that removed the error. But now eureka isn't registered and won't show up in https://github.com/codecentric/spring-boot-admin and I have to register it manually.

Is eureka server as eureka client a bad thing?

magnusheino avatar Apr 12 '16 14:04 magnusheino

Uh... deep water :)

EurekaBootStrap.java says logger.info("Initialized server context"); the line after that, int registryCount = registry.syncUp(); blocks for a while, since I don't have a neighboring eureka node. That means registry.openForTraffic(applicationInfoManager, registryCount); doesn't run. Last method call in openForTraffic is super.postInit() that should initialize renewsLastMin. This isn't executed at the moment that something else (eureka client registration?) is executed, and I get a stacktrace that renewsLastMin is null:

java.lang.NullPointerException: null at com.netflix.eureka.registry.AbstractInstanceRegistry.renew(AbstractInstanceRegistry.java:379) at com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl.renew(PeerAwareInstanceRegistryImpl.java:401) at org.springframework.cloud.netflix.eureka.server.InstanceRegistry.renew(InstanceRegistry.java:127) at com.netflix.eureka.resources.InstanceResource.renewLease(InstanceResource.java:112)

Makes sense? What should I change?

Current config:

info:
  version: "@project.version@"
server:
  port: 8761
management:
  port: 8762
eureka:
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: http://${spring.cloud.client.hostname}:8761/eureka/
    healthcheck:
      enabled: true
  instance:
    metadataMap:
      management-url: http://${spring.cloud.client.hostname}:${management.port}
      management-port: ${management.port}
    leaseRenewalIntervalInSeconds: 10
    prefer-ip-address: true
    hostname: ${spring.cloud.client.hostname}
  server:
    waitTimeInMsWhenSyncEmpty: 0

This is the first process that I start...

magnusheino avatar Apr 12 '16 15:04 magnusheino

I had eureka.server.waitTimeInMsWhenSyncEmpty=0. Added eureka.server.registrySyncRetries=0 and the problem seems to be gone... I do get Changing status to UP in the log now, and that was not there before.

The weird thing is why this started today. I have been running this project for a few weeks now... :-P

magnusheino avatar Apr 12 '16 15:04 magnusheino

I also faced the same issue and I figure out the cause: I use a microservice approach and I updated only the "client" service to the new Brixton.RELEASE and not the eureka server itself. Using the Brixton.RELEASE as client and Angel.SR6 as eureka server wouldn't work.

nanachimi avatar Jun 05 '16 09:06 nanachimi

Hello all, (UPDATE 2018)

I just came accross this issue. At least in Spring cloud version Finchley.RC1 zuul and eurke client starters doesnt go along with each other. Properbly because zuul already provides a DiscoveryClient.

Tobia5 avatar May 11 '18 06:05 Tobia5

@Tobia5 probably not related and you should be able to have both the Eureka and Zuul starters on your classpath and things should run fine.

ryanjbaxter avatar May 11 '18 18:05 ryanjbaxter

I agree

Tobia5 avatar Jun 21 '18 21:06 Tobia5