thingsboard / dart_thingsboard_client

ThingsBoard API client library for Dart developers.
BSD 3-Clause "New" or "Revised" License
59 stars 30 forks source link

[BUG] AlarmDataCmd incorrect behaviour over TelemetrySubscriber (websockets) #19

Closed alenas closed 8 months ago

alenas commented 9 months ago

I have Flutter web application. We are paying customer and I tried both PE and community version of dart client - we have this problem since version 1.0.2 till the latest.

There is one subscription to get latest device data and another to get latest alarm data. The problems are:

  1. AlarmDataCmd kills the other EntityDataQuery (as then the other does not receive any response).
  2. AlarmDataCmd behaves incorrectly, as it creates a new websocket every 1 second or so, instead of communicating over the same open websocket (like EntityDataQuery does) - as you can see here in Developer Console: image

So if there is no AlarmDataQuery - then everything works fine.

sample code that I am using:

var alarmFields = <EntityKey>[ EntityKey(type: EntityKeyType.ALARM_FIELD, key: "createdTime"), EntityKey(type: EntityKeyType.ALARM_FIELD, key: "type"), EntityKey(type: EntityKeyType.ALARM_FIELD, key: "severity"), EntityKey(type: EntityKeyType.ALARM_FIELD, key: "status"), ]; var alarmQuery = AlarmDataQuery( entityFilter: DeviceTypeFilter(deviceType: "v4"), alarmFields: alarmFields, pageLink: AlarmDataPageLink( pageSize: 1000, searchPropagatedAlarms: true, timeWindow: 604800000, sortOrder: EntityDataSortOrder(key: EntityKey(type: EntityKeyType.ALARM_FIELD, key: "createdTime"), direction: EntityDataSortOrderDirection.DESC))); subscription = TelemetrySubscriber(client.getTelemetryService(), [AlarmDataCmd(cmdId: 101, query: alarmQuery)]); subscription!.alarmDataStream.listen(onData, onError: onError, onDone: onDone, cancelOnError: true); subscription!.subscribe();

vvlladd28 commented 8 months ago

@alenas Thanks for reporting the problem This has already been fixed by a commit on master: see https://github.com/thingsboard/dart_thingsboard_client/commit/ed042f8961977ede14a503a07cfb978fe7f24b9e