{"record":{"id":"4685879659a5169b","repo":"alibaba/nacos","slug":"unsupported-connection-type","errorCode":null,"errorMessage":"unsupported connection type :{}","messagePattern":"unsupported connection type :(.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClientFactory.java","lineNumber":122,"sourceCode":"            labels, null);\n    }\n    \n    /**\n     * create a rpc client.\n     *\n     * @param clientName         client name.\n     * @param connectionType     client type.\n     * @param threadPoolCoreSize grpc thread pool core size\n     * @param threadPoolMaxSize  grpc thread pool max size\n     * @param tlsConfig          tlsconfig\n     * @return rpc client.\n     */\n    public static RpcClient createClient(String clientName, ConnectionType connectionType,\n        Integer threadPoolCoreSize,\n        Integer threadPoolMaxSize, Map<String, String> labels, RpcClientTlsConfig tlsConfig) {\n        \n        if (!ConnectionType.GRPC.equals(connectionType)) {\n            throw new UnsupportedOperationException(\n                \"unsupported connection type :\" + connectionType.getType());\n        }\n        \n        return CLIENT_MAP.computeIfAbsent(clientName, clientNameInner -> {\n            LOGGER.info(\"[RpcClientFactory] create a new rpc client of \" + clientName);\n            return new GrpcSdkClient(clientNameInner, threadPoolCoreSize, threadPoolMaxSize, labels,\n                tlsConfig);\n        });\n    }\n    \n    /**\n     * create a rpc client.\n     *\n     * @param clientName         client name.\n     * @param connectionType     client type.\n     * @param grpcClientConfig   grpc client config.\n     * @return rpc client.\n     */","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClientFactory.java#L104-L140","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Always pass ConnectionType.GRPC to createClient.","If you passed null, trace the caller that produced the null ConnectionType and fix it.","Remove any branching that selects a non-GRPC type; the factory does not support it."],"exampleFix":"// before\nRpcClient c = RpcClientFactory.createClient(name, someOtherType, core, max, labels, tls);\n\n// after\nRpcClient c = RpcClientFactory.createClient(name, ConnectionType.GRPC, core, max, labels, tls);","handlingStrategy":"validation","validationCode":"static RpcClient safeCreate(String name, ConnectionType type, int core, int max, Map<String,String> labels, RpcClientTlsConfig tls) {\n    if (!ConnectionType.GRPC.equals(type)) throw new IllegalArgumentException(\"only GRPC supported\");\n    return RpcClientFactory.createClient(name, type, core, max, labels, tls);\n}","typeGuard":null,"tryCatchPattern":"try {\n    client = RpcClientFactory.createClient(name, type, core, max, labels, tls);\n} catch (UnsupportedOperationException uoe) {\n    // caller passed a non-GRPC type; default to GRPC or fail fast\n}","preventionTips":["Hard-code ConnectionType.GRPC at every createClient call site.","Reject null ConnectionType values at the boundary that produces them."],"tags":["rpc-client","factory","connection-type","grpc","validation"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}