diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/Config.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/Config.java index 3857a5705..73b51ba62 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/Config.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/Config.java @@ -41,7 +41,7 @@ public class Config { /** * application and service registry check interval */ - public static long APP_AND_SERVICE_REGISTER_CHECK_INTERVAL = 10; + public static long APP_AND_SERVICE_REGISTER_CHECK_INTERVAL = 3; /** * discovery rest check interval */ diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java index 0b18cc3d5..bced1a9eb 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java @@ -87,7 +87,9 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList @Override public void run() { - if (CONNECTED.equals(status)) { + boolean shouldTry = true; + while (CONNECTED.equals(status) & shouldTry) { + shouldTry = false; try { if (RemoteDownstreamConfig.Agent.APPLICATION_ID == DictionaryUtil.nullValue()) { if (applicationRegisterServiceBlockingStub != null) { @@ -95,6 +97,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList Application.newBuilder().addApplicationCode(Config.Agent.APPLICATION_CODE).build()); if (applicationMapping.getApplicationCount() > 0) { RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplication(0).getValue(); + shouldTry = true; } } } else { @@ -119,6 +122,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList .setRegisterTime(System.currentTimeMillis()) .setOsinfo(OSUtil.buildOSInfo()) .build()); + needRegisterRecover = true; } else { if (lastSegmentTime - System.currentTimeMillis() > 60 * 1000) { instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder()