浏览代码

优化tcp网关

zhou-hao 4 年之前
父节点
当前提交
349cdbe3d3

+ 3 - 2
jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/device/TcpServerDeviceGateway.java

@@ -151,10 +151,11 @@ class TcpServerDeviceGateway implements DeviceGateway, MonitorSupportDeviceGatew
             return client
                 .subscribe()
                 .filter(tcp -> started.get())
-                .doOnCancel(client::shutdown)
+                .publishOn(Schedulers.parallel())
                 .flatMap(this::handleTcpMessage)
                 .onErrorContinue((err, ignore) -> log.error(err.getMessage(), err))
-                .then();
+                .then()
+                .doOnCancel(client::shutdown);
         }
 
         Mono<Void> handleTcpMessage(TcpMessage message) {