Netflix/eureka

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

Open

#1,221 创建于 2019年6月22日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Java (12,190 star) (3,712 fork)batch import
bughelp wanted

描述

  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

贡献者指南