Netflix/eureka

eureka client not register it self ofter a long time network connection problem

Aperta

#1221 aperta il 22 giu 2019

 (1 commento) (0 reazioni) (0 assegnatari)Java (3712 fork)batch import
bughelp wanted

Metriche repository

Star
 (12.190 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

  1. after a long time network connection problem
  2. client instance is removed from eureka server
  3. renew thread try to send heart beat but eureka server return 404
  4. sendHeartBeat throw TransportException with 404 status code
  5. in the code below, try to re-register client but cause step 4 throw exception, so the re-register logic not executed

boolean renew() {
        EurekaHttpResponse<InstanceInfo> httpResponse;
        try {
            httpResponse = eurekaTransport.registrationClient.sendHeartBeat(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo, null);
            logger.debug(PREFIX + "{} - Heartbeat status: {}", appPathIdentifier, httpResponse.getStatusCode());
            if (httpResponse.getStatusCode() == Status.NOT_FOUND.getStatusCode()) {
                REREGISTER_COUNTER.increment();
                logger.info(PREFIX + "{} - Re-registering apps/{}", appPathIdentifier, instanceInfo.getAppName());
                long timestamp = instanceInfo.setIsDirtyWithTime();
                boolean success = register();
                if (success) {
                    instanceInfo.unsetIsDirty(timestamp);
                }
                return success;
            }
            return httpResponse.getStatusCode() == Status.OK.getStatusCode();
        } catch (Throwable e) {
            logger.error(PREFIX + "{} - was unable to send heartbeat!", appPathIdentifier, e);
            return false;
        }
    }
  1. Eureka client always retry to send heartbeat with no re-register

Guida contributor