alibaba/nacos · error · UnsupportedOperationException

unsupported connection type :{}

Error message

unsupported connection type :{}

What it means

RpcClientFactory.createClient (5-arg overload) throws UnsupportedOperationException because Nacos's RPC layer only implements the GRPC ConnectionType. Any other ConnectionType value fails the guard `!ConnectionType.GRPC.equals(connectionType)` before a client is created or cached.

Source

Thrown at common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClientFactory.java:122

            labels, null);
    }
    
    /**
     * create a rpc client.
     *
     * @param clientName         client name.
     * @param connectionType     client type.
     * @param threadPoolCoreSize grpc thread pool core size
     * @param threadPoolMaxSize  grpc thread pool max size
     * @param tlsConfig          tlsconfig
     * @return rpc client.
     */
    public static RpcClient createClient(String clientName, ConnectionType connectionType,
        Integer threadPoolCoreSize,
        Integer threadPoolMaxSize, Map<String, String> labels, RpcClientTlsConfig tlsConfig) {
        
        if (!ConnectionType.GRPC.equals(connectionType)) {
            throw new UnsupportedOperationException(
                "unsupported connection type :" + connectionType.getType());
        }
        
        return CLIENT_MAP.computeIfAbsent(clientName, clientNameInner -> {
            LOGGER.info("[RpcClientFactory] create a new rpc client of " + clientName);
            return new GrpcSdkClient(clientNameInner, threadPoolCoreSize, threadPoolMaxSize, labels,
                tlsConfig);
        });
    }
    
    /**
     * create a rpc client.
     *
     * @param clientName         client name.
     * @param connectionType     client type.
     * @param grpcClientConfig   grpc client config.
     * @return rpc client.
     */

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Always pass ConnectionType.GRPC to createClient.
  2. If you passed null, trace the caller that produced the null ConnectionType and fix it.
  3. Remove any branching that selects a non-GRPC type; the factory does not support it.

Example fix

// before
RpcClient c = RpcClientFactory.createClient(name, someOtherType, core, max, labels, tls);

// after
RpcClient c = RpcClientFactory.createClient(name, ConnectionType.GRPC, core, max, labels, tls);
Defensive patterns

Strategy: validation

Validate before calling

static RpcClient safeCreate(String name, ConnectionType type, int core, int max, Map<String,String> labels, RpcClientTlsConfig tls) {
    if (!ConnectionType.GRPC.equals(type)) throw new IllegalArgumentException("only GRPC supported");
    return RpcClientFactory.createClient(name, type, core, max, labels, tls);
}

Try / catch

try {
    client = RpcClientFactory.createClient(name, type, core, max, labels, tls);
} catch (UnsupportedOperationException uoe) {
    // caller passed a non-GRPC type; default to GRPC or fail fast
}

Prevention

When it happens

Trigger: Passing a ConnectionType other than GRPC (e.g. a custom enum value or a future/legacy type) to createClient. The guard runs synchronously on the calling thread.

Common situations: Custom code constructing an RpcClient with a wrong or stub ConnectionType. Copy-paste from a branch that used an experimental type. Passing null (the equals check returns false for null).

Related errors


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