diff --git a/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java b/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java index edb2d7b7fa8..0af50ff8596 100644 --- a/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java +++ b/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java @@ -260,7 +260,8 @@ private void handleWsAlarmCountCmd(WebSocketSessionRef sessionRef, AlarmCountCmd @Override public void sendUpdate(String sessionId, int cmdId, TelemetrySubscriptionUpdate update) { - doSendUpdate(sessionId, cmdId, update); + // We substitute the subscriptionId with cmdId for old-style subscriptions. + doSendUpdate(sessionId, cmdId, update.copyWithNewSubscriptionId(cmdId)); } @Override diff --git a/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java b/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java index 1320a055cd4..aa1a44096d4 100644 --- a/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java +++ b/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.service.ws.telemetry.sub; +import lombok.AllArgsConstructor; import org.thingsboard.server.common.data.kv.TsKvEntry; import org.thingsboard.server.service.subscription.SubscriptionErrorCode; @@ -26,8 +27,8 @@ import java.util.TreeMap; import java.util.stream.Collectors; +@AllArgsConstructor public class TelemetrySubscriptionUpdate { - private final int subscriptionId; private int errorCode; private String errorMsg; @@ -93,6 +94,10 @@ public String getErrorMsg() { return errorMsg; } + public TelemetrySubscriptionUpdate copyWithNewSubscriptionId(int subscriptionId){ + return new TelemetrySubscriptionUpdate(subscriptionId, errorCode, errorMsg, data); + } + @Override public String toString() { StringBuilder result = new StringBuilder("TelemetrySubscriptionUpdate [subscriptionId=" + subscriptionId + ", errorCode=" + errorCode + ", errorMsg=" + errorMsg + ", data=");