{"record":{"id":"0f1960f4268c5b2f","repo":"alibaba/nacos","slug":"500-0f1960","errorCode":"500","errorMessage":"Request nacos server failed: {}","messagePattern":"Request nacos server failed: (.+?)","errorType":"exception","errorClass":"NacosException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/nacos/client/lock/remote/grpc/LockGrpcClient.java","lineNumber":465,"sourceCode":"    }\n    \n    private <T extends Response> T requestToServer(AbstractLockRequest request,\n        Class<T> responseClass)\n        throws NacosException {\n        try {\n            request.putAllHeader(getSecurityHeaders());\n            long timeout = requestTimeout > 0 ? requestTimeout : 15000L;\n            Response response = rpcClient.request(request, timeout);\n            if (ResponseCode.SUCCESS.getCode() != response.getResultCode()) {\n                throw new NacosException(response.getErrorCode(), response.getMessage());\n            }\n            if (responseClass.isAssignableFrom(response.getClass())) {\n                return (T) response;\n            }\n        } catch (NacosException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new NacosException(NacosException.SERVER_ERROR, \"Request nacos server failed: \",\n                e);\n        }\n        throw new NacosException(NacosException.SERVER_ERROR, \"Server return invalid response\");\n    }\n    \n    private boolean isAbilitySupportedByServer() {\n        return rpcClient.getConnectionAbility(\n            AbilityKey.SERVER_DISTRIBUTED_LOCK) == AbilityStatus.SUPPORTED;\n    }\n}\n","sourceCodeStart":447,"sourceCodeEnd":476,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client/src/main/java/com/alibaba/nacos/client/lock/remote/grpc/LockGrpcClient.java#L447-L476","documentation":"Thrown by LockGrpcClient.requestToServer when an unexpected (non-NacosException) Exception occurs during the gRPC request — e.g. serialization failure, connection error during marshalling, or an internal client error. It is wrapped into NacosException with code SERVER_ERROR (500). NacosException instances are rethrown as-is (so server-side error codes pass through); only generic exceptions get this generic wrap.","triggerScenarios":"A transport/serialization/codec error while sending or receiving a lock RPC; the RpcClient.request() throws something other than NacosException (e.g. IllegalStateException, IOException from the gRPC layer); connection state corruption during the call.","commonSituations":"Transient gRPC channel errors; malformed LockInstance causing serialization issues; connection torn down mid-call; TLS/handshake errors surfacing as generic exceptions.","solutions":["Inspect the attached cause (NacosException.getCause()) to identify the real transport/codec problem.","Retry the lock operation once if the cause is transient (connection reset) — the operation is idempotent for release/renew.","Check gRPC client health and connection state; ensure the LockGrpcClient is not shut down.","Verify the LockInstance fields are valid and serializable before sending."],"exampleFix":"// before\nResponse r = requestToServer(request, LockOperationResponse.class); // NacosException 500\n\n// after\ntry {\n    requestToServer(request, LockOperationResponse.class);\n} catch (NacosException e) {\n    LOGGER.error(\"Lock RPC failed, code={}, cause=\", e.getErrCode(), e.getCause());\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { requestToServer(request, LockOperationResponse.class); } catch (NacosException e) { LOGGER.error(\"Lock RPC failed, code={}, cause=\", e.getErrCode(), e.getCause()); throw e; }","preventionTips":["Inspect the wrapped cause to identify the real transport/codec problem.","Retry idempotent operations (release/renew) once on transient errors.","Ensure the gRPC client is healthy and not shut down before issuing RPCs."],"tags":["lock","grpc","network","transport-error","server-error"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}