{"record":{"id":"fcc0680e8e41ede1","repo":"YunaiV/yudao-cloud","slug":"createprotocol-s-s","errorCode":null,"errorMessage":"[createProtocol][协议实例 %s 的协议类型 %s 暂不支持]","messagePattern":"\\[createProtocol\\]\\[协议实例 (.+?) 的协议类型 (.+?) 暂不支持\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/IotProtocolManager.java","lineNumber":122,"sourceCode":"                return createHttpProtocol(config);\n            case TCP:\n                return createTcpProtocol(config);\n            case UDP:\n                return createUdpProtocol(config);\n            case COAP:\n                return createCoapProtocol(config);\n            case WEBSOCKET:\n                return createWebSocketProtocol(config);\n            case MQTT:\n                return createMqttProtocol(config);\n            case EMQX:\n                return createEmqxProtocol(config);\n            case MODBUS_TCP_CLIENT:\n                return createModbusTcpClientProtocol(config);\n            case MODBUS_TCP_SERVER:\n                return createModbusTcpServerProtocol(config);\n            default:\n                throw new IllegalArgumentException(String.format(\n                        \"[createProtocol][协议实例 %s 的协议类型 %s 暂不支持]\", config.getId(), protocolType));\n        }\n    }\n\n    /**\n     * 创建 HTTP 协议实例\n     *\n     * @param config 协议实例配置\n     * @return HTTP 协议实例\n     */\n    private IotHttpProtocol createHttpProtocol(IotGatewayProperties.ProtocolProperties config) {\n        return new IotHttpProtocol(config);\n    }\n\n    /**\n     * 创建 TCP 协议实例\n     *\n     * @param config 协议实例配置","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/YunaiV/yudao-cloud/blob/477be9dd49ab7223a972a6abdff0684d6423dec3/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/IotProtocolManager.java#L104-L140","documentation":"IotProtocolManager.createProtocol switches over the configured protocol type (HTTP, COAP, WEBSOCKET, MQTT, EMQX, MODBUS_TCP_CLIENT, MODBUS_TCP_SERVER) and throws IllegalArgumentException from the default branch when the value is anything else. The protocolType derives from the IoT protocol-instance config in yudao.gateway.properties, so this fires when a config entry's type is misspelled, unknown to this gateway build, or was written by a newer module version.","triggerScenarios":"yudao.gateway config (or DB-backed protocol instance) with type 'TCP', 'MQTTS', or lowercase 'mqtt' — not matching the enum values; gateway jar older than the IoT server that emitted a new protocol type; YAML typo in the type key.","commonSituations":"Upgrading the IoT module but not the gateway (or vice versa); hand-editing gateway properties; copying a config example from docs of a different release; enum renamed between versions.","solutions":["Set type to one of the supported enum values: HTTP, COAP, WEBSOCKET, MQTT, EMQX, MODBUS_TCP_CLIENT, MODBUS_TCP_SERVER","Keep the IoT gateway jar and IoT server module on the same release so the protocol type set matches","Check YAML spelling/case of the type field after editing"],"exampleFix":"# before\nyudao.gateway.protocols:\n  - id: 1\n    type: tcp        # unsupported\n\n# after\nyudao.gateway.protocols:\n  - id: 1\n    type: MQTT       # one of HTTP/COAP/WEBSOCKET/MQTT/EMQX/MODBUS_TCP_CLIENT/MODBUS_TCP_SERVER","handlingStrategy":"type-guard","validationCode":"Set<String> supported = Set.of(\"HTTP\",\"COAP\",\"WEBSOCKET\",\"MQTT\",\"EMQX\",\"MODBUS_TCP_CLIENT\",\"MODBUS_TCP_SERVER\");\nif (!supported.contains(protocolType)) {\n    throw new IllegalArgumentException(\"协议类型必须为 \" + supported);\n}","typeGuard":"boolean isSupportedProtocol(String type) {\n    return Arrays.stream(IotGatewayProperties.ProtocolProperties.ProtocolType.values())\n        .anyMatch(t -> t.name().equalsIgnoreCase(StrUtil.trimToEmpty(type)));\n}","tryCatchPattern":null,"preventionTips":["Validate the type field against the enum at config load time (fail fast at startup)","Keep gateway and server module versions in lockstep","Lint YAML gateway configs in CI"],"tags":["iot","gateway","protocol","config","enum"],"backgroundTag":null,"analyzedSha":"477be9dd49ab7223a972a6abdff0684d6423dec3","analyzedAt":"2026-08-14T13:35:31.121Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}