alibaba/nacos · error · NacosException

500

500

Error message

Request nacos server failed: {}

What it means

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.

Source

Thrown at client/src/main/java/com/alibaba/nacos/client/lock/remote/grpc/LockGrpcClient.java:465

    }
    
    private <T extends Response> T requestToServer(AbstractLockRequest request,
        Class<T> responseClass)
        throws NacosException {
        try {
            request.putAllHeader(getSecurityHeaders());
            long timeout = requestTimeout > 0 ? requestTimeout : 15000L;
            Response response = rpcClient.request(request, timeout);
            if (ResponseCode.SUCCESS.getCode() != response.getResultCode()) {
                throw new NacosException(response.getErrorCode(), response.getMessage());
            }
            if (responseClass.isAssignableFrom(response.getClass())) {
                return (T) response;
            }
        } catch (NacosException e) {
            throw e;
        } catch (Exception e) {
            throw new NacosException(NacosException.SERVER_ERROR, "Request nacos server failed: ",
                e);
        }
        throw new NacosException(NacosException.SERVER_ERROR, "Server return invalid response");
    }
    
    private boolean isAbilitySupportedByServer() {
        return rpcClient.getConnectionAbility(
            AbilityKey.SERVER_DISTRIBUTED_LOCK) == AbilityStatus.SUPPORTED;
    }
}

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Inspect the attached cause (NacosException.getCause()) to identify the real transport/codec problem.
  2. Retry the lock operation once if the cause is transient (connection reset) — the operation is idempotent for release/renew.
  3. Check gRPC client health and connection state; ensure the LockGrpcClient is not shut down.
  4. Verify the LockInstance fields are valid and serializable before sending.

Example fix

// before
Response r = requestToServer(request, LockOperationResponse.class); // NacosException 500

// after
try {
    requestToServer(request, LockOperationResponse.class);
} catch (NacosException e) {
    LOGGER.error("Lock RPC failed, code={}, cause=", e.getErrCode(), e.getCause());
    throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try { requestToServer(request, LockOperationResponse.class); } catch (NacosException e) { LOGGER.error("Lock RPC failed, code={}, cause=", e.getErrCode(), e.getCause()); throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: Transient gRPC channel errors; malformed LockInstance causing serialization issues; connection torn down mid-call; TLS/handshake errors surfacing as generic exceptions.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/0f1960f4268c5b2f. Report an issue: GitHub.