alibaba/nacos · error · NacosException

500

500

Error message

{}

What it means

GrpcConnection.request() wraps any exception thrown while waiting on the gRPC ListenableFuture (timeout, cancellation, channel error, interrupted) into a NacosException with SERVER_ERROR (500) and the original exception as its cause. The literal message is the exception's own toString via the NacosException(Throwable) constructor.

Source

Thrown at common/src/main/java/com/alibaba/nacos/common/remote/client/grpc/GrpcConnection.java:81

    
    public GrpcConnection(RpcClient.ServerInfo serverInfo, Executor executor) {
        super(serverInfo);
        this.executor = executor;
    }
    
    @Override
    public Response request(Request request, long timeouts) throws NacosException {
        Payload grpcRequest = GrpcUtils.convert(request);
        ListenableFuture<Payload> requestFuture = grpcFutureServiceStub.request(grpcRequest);
        Payload grpcResponse;
        try {
            if (timeouts <= 0) {
                grpcResponse = requestFuture.get();
            } else {
                grpcResponse = requestFuture.get(timeouts, TimeUnit.MILLISECONDS);
            }
        } catch (Exception e) {
            throw new NacosException(NacosException.SERVER_ERROR, e);
        }
        
        return (Response) GrpcUtils.parse(grpcResponse);
    }
    
    @Override
    public RequestFuture requestFuture(Request request) throws NacosException {
        Payload grpcRequest = GrpcUtils.convert(request);
        
        final ListenableFuture<Payload> requestFuture = grpcFutureServiceStub.request(grpcRequest);
        return new RequestFuture() {
            
            @Override
            public boolean isDone() {
                return requestFuture.isDone();
            }
            
            @Override

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Increase the per-request timeout passed to request() if timeouts dominate.
  2. Inspect the wrapped cause (NacosException.getCause()) to distinguish timeout vs server error vs interruption.
  3. For server-side failures, check the Nacos server log for the corresponding request handler exception.
  4. For interruptions, ensure the calling thread is not being prematurely interrupted and handle InterruptedException cleanly.

Example fix

// before — fixed short timeout causing frequent timeouts
Response r = connection.request(req, 500);

// after — timeout sized to the operation, plus cause inspection
try {
    Response r = connection.request(req, 5000);
} catch (NacosException ne) {
    Throwable cause = ne.getCause(); // TimeoutException? ExecutionException?
}
Defensive patterns

Strategy: try-catch

Validate before calling

static Response requestWithAdequateTimeout(GrpcConnection conn, Request req, long timeout) throws NacosException {
    if (timeout <= 0) throw new IllegalArgumentException("timeout must be positive");
    return conn.request(req, timeout);
}

Try / catch

try {
    response = connection.request(req, timeout);
} catch (NacosException ne) {
    Throwable cause = ne.getCause();
    if (cause instanceof TimeoutException) {
        // increase timeout or back off and retry
    } else if (cause instanceof ExecutionException) {
        // server-side failure — check server logs
    } else { throw ne; }
}

Prevention

When it happens

Trigger: Calling request() through the connection and the gRPC future.get()/get(timeout) throws: TimeoutException (deadline exceeded), InterruptedException, ExecutionException (server-side failure surfaced through the future), or CancellationException.

Common situations: Server slow to respond so the timeoutMills deadline is exceeded; server-side handler threw (ExecutionException wraps it); channel went unhealthy between send and receive; client thread interrupted; gRPC deadline/cancellation propagated.

Related errors


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