{"record":{"id":"f851f49885259bf4","repo":"alibaba/nacos","slug":"error","errorCode":"{}","errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":"NacosException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClient.java","lineNumber":693,"sourceCode":"                if (response == null) {\n                    throw new NacosException(SERVER_ERROR, \"Unknown Exception.\");\n                }\n                if (response instanceof ErrorResponse) {\n                    if (response.getErrorCode() == NacosException.UN_REGISTER) {\n                        synchronized (this) {\n                            waitReconnect = true;\n                            if (rpcClientStatus.compareAndSet(RpcClientStatus.RUNNING,\n                                RpcClientStatus.UNHEALTHY)) {\n                                LoggerUtils.printIfErrorEnabled(LOGGER,\n                                    \"Connection is unregistered, switch server, connectionId = {}, request = {}\",\n                                    currentConnection.getConnectionId(),\n                                    request.getClass().getSimpleName());\n                                switchServerAsync();\n                            }\n                        }\n                        \n                    }\n                    throw new NacosException(response.getErrorCode(), response.getMessage());\n                }\n                // return response.\n                lastActiveTimeStamp = System.currentTimeMillis();\n                return response;\n                \n            } catch (Throwable e) {\n                if (waitReconnect) {\n                    try {\n                        // wait client to reconnect.\n                        Thread.sleep(Math.min(100, timeoutMills / 3));\n                    } catch (Exception exception) {\n                        // Do nothing.\n                    }\n                }\n                \n                LoggerUtils.printIfErrorEnabled(LOGGER,\n                    \"Send request fail, request = {}, retryTimes = {}, errorMessage = {}\", request,\n                    retryTimes,","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClient.java#L675-L711","documentation":"RpcClient.request() rethrows the server's own error code and message when the transport returns an ErrorResponse (a protobuf Response with a non-zero errorCode). The literal error code/message come straight from the server, so this entry is a generic re-throw surface: the actual meaning is whatever the server-side handler attached. The only special case is UN_REGISTER (301), which additionally triggers an async server switch before rethrowing.","triggerScenarios":"Any server-side request handler that returns an ErrorResponse — for example permission denied, resource not found, bad request params, or the connection being force-unregistered (301). After the retry loop catches the thrown NacosException it eventually surfaces both code and message verbatim from `response.getErrorCode()` / `response.getMessage()`.","commonSituations":"Missing or expired access token / no permission (server returns auth error code). Request payload fails server-side validation. Server initiated connection un-registration (overload, restart, duplicate connection). Resource does not exist (config dataId not found, naming service missing).","solutions":["Read the embedded errorCode and message to identify the true cause; the wrapper here only forwards them.","For UN_REGISTER (301), the client auto-switches servers; allow time for reconnect and retry the request once isRunning() returns true.","For auth/permission codes, refresh credentials/tokens and verify the user has the required permission on the resource.","For validation codes, correct the request fields (dataId/group/namespace) per the server message."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    response = client.request(req, timeout);\n} catch (NacosException ne) {\n    switch (ne.getErrCode()) {\n        case NacosException.UN_REGISTER: // 301 — server dropped connection, will reconnect\n        case NacosException.NO_RIGHT:    // auth — refresh token then retry\n        default: // surface other server error codes per their documented meaning\n    }\n}","preventionTips":["Branch on getErrCode() to handle each server error category specifically.","For 301 (UN_REGISTER), allow the auto server-switch to complete before retrying.","Keep auth tokens fresh to avoid permission-based ErrorResponse codes."],"tags":["rpc-client","grpc","server-error","forwarded","unregister"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}