RainYuY commented on code in PR #15594:
URL: https://github.com/apache/dubbo/pull/15594#discussion_r2243143960


##########
dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java:
##########
@@ -114,8 +115,17 @@ public static NacosNamingServiceWrapper 
createNamingService(URL connectionURL) {
         boolean check = connectionURL.getParameter(NACOS_CHECK_KEY, true);
         int retryTimes = connectionURL.getPositiveParameter(NACOS_RETRY_KEY, 
10);
         int sleepMsBetweenRetries = 
connectionURL.getPositiveParameter(NACOS_RETRY_WAIT_KEY, 10);
-        NacosConnectionManager nacosConnectionManager =
-                new NacosConnectionManager(connectionURL, check, retryTimes, 
sleepMsBetweenRetries);
+        NacosConnectionManager nacosConnectionManager;
+        try {
+            nacosConnectionManager =
+                    new NacosConnectionManager(connectionURL, check, 
retryTimes, sleepMsBetweenRetries);
+        } catch (IllegalStateException e) {
+            if (RegistryFactory.isCheck(connectionURL)) {
+                throw e;
+            }
+            nacosConnectionManager =
+                    new NacosConnectionManager(connectionURL, false, 
retryTimes, sleepMsBetweenRetries);

Review Comment:
   After trying it out, I got the result.
   ```
   23:41:19.981 |-WARN  [DubboRegistryRetryTimer-thread-1] 
registry.nacos.NacosNamingServiceWrapper:    -|  [DUBBO] Failed to request 
nacos naming server. Dubbo will try to retry in 10. Try times: 6, dubbo 
version: 3.3.6-SNAPSHOT, current host: 192.168.31.224, error code: 1-37. This 
may be caused by , go to https://dubbo.apache.org/faq/1/37 to find 
instructions. 
   com.alibaba.nacos.api.exception.NacosException: Client not connected, 
current status:STARTING
        at 
com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:645) 
~[nacos-client-2.5.1.jar:?]
        at 
com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:624) 
~[nacos-client-2.5.1.jar:?]
        at 
com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.requestToServer(NamingGrpcClientProxy.java:449)
 ~[nacos-client-2.5.1.jar:?]
        at 
com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.doRegisterService(NamingGrpcClientProxy.java:252)
 ~[nacos-client-2.5.1.jar:?]
        at 
com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.registerServiceForEphemeral(NamingGrpcClientProxy.java:147)
 ~[nacos-client-2.5.1.jar:?]
        at 
com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.registerService(NamingGrpcClientProxy.java:138)
 ~[nacos-client-2.5.1.jar:?]
        at 
com.alibaba.nacos.client.naming.remote.NamingClientProxyDelegate.registerService(NamingClientProxyDelegate.java:96)
 ~[nacos-client-2.5.1.jar:?]
        at 
com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:161)
 ~[nacos-client-2.5.1.jar:?]
        at 
org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper.lambda$registerInstance$5(NacosNamingServiceWrapper.java:133)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper.accept(NacosNamingServiceWrapper.java:495)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper.registerInstance(NacosNamingServiceWrapper.java:133)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.registry.nacos.NacosRegistry.doRegister(NacosRegistry.java:205)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.registry.retry.FailedRegisteredTask.doRetry(FailedRegisteredTask.java:33)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.registry.retry.AbstractRetryTask.run(AbstractRetryTask.java:127)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.common.timer.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:654)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.common.timer.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:733)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at 
org.apache.dubbo.common.timer.HashedWheelTimer$Worker.run(HashedWheelTimer.java:455)
 ~[dubbo-3.3.6-SNAPSHOT.jar:3.3.6-SNAPSHOT]
        at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
   
   ```
   It will return to normal once the Nacos server is back online.
   It's different from metadata or the config center — I think they should 
follow the same behavior.
   This needs some discussion.
   
   @zrlw @AlbumenJ @oxsean 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to