Parcourir la source

优化MQTT网关

zhou-hao il y a 4 ans
Parent
commit
35b088388e

+ 3 - 1
jetlinks-components/network-component/mqtt-component/src/main/java/org/jetlinks/community/network/mqtt/gateway/device/MqttServerDeviceGateway.java

@@ -127,7 +127,9 @@ class MqttServerDeviceGateway implements DeviceGateway, MonitorSupportDeviceGate
                             if (!deviceId.equals(device.getDeviceId())) {
                                 return registry
                                     .getDevice(deviceId)
-                                    .map(operator -> Tuples.of(operator, resp, connection));
+                                    .map(operator -> Tuples.of(operator, resp, connection))
+                                    .switchIfEmpty(Mono.fromRunnable(() -> connection.reject(MqttConnectReturnCode.CONNECTION_REFUSED_IDENTIFIER_REJECTED)))
+                                    ;
                             }
                             return Mono.just(Tuples.of(device, resp, connection));
                         })