Realtime data issue in cumolocity

Realtime data transmit from device but sometime receive in Realtime Observable and sometimes not receive. So that my widget is not update through the Realtime data.

My tenant version details is:-Backend: 1014.0.213 UI: 1011.0.14

Implementation Of Realtime: - coding part

this.subscription=this.realtime.subscribe(/measurements/ + deviceId, measurementNotification => {
debugger
try {

    let selectedSeriesWithType = this.supportedSeries1[devices.text];
    let seriesval1 = selectedSeriesWithType.split('.')   
    if (measurementNotification.data.data[seriesval1[0]] !== undefined && measurementNotification.data.data[seriesval1[0]][seriesval1[1]] !== undefined) {
      const measurementValue= measurementNotification.data.data[seriesval1[0]][seriesval1[1]].value;
      
        if(measurementValue){
          this.setValuesToChart(selectedSeriesWithType, measurementValue) 
        }

    }
  } catch (e) {
    console.log("Advanced Radial Gauge Widget - " + e);
}

Please suggest me, anything is wrong in my code or give me solution.

Thanks
Rahul

Hi Rahul, I’ve tried to reproduce your case with the following code and a temperature device simulator (Device Management - Cumulocity IoT Guides, I modified the simulator to also send other types of measurements than only c8y_Temperature.T):

const deviceId = 6201;
const devices = {
  text: '?'
};
const supportedSeries1 = {
  '?': 'c8y_Temperature.T'
};

this.realtime.subscribe('/measurements/' + deviceId, measurementNotification => {
  console.log(measurementNotification);
  try {
    const selectedSeriesWithType = supportedSeries1[devices.text];
    const seriesval1 = selectedSeriesWithType.split('.');
    if (
      measurementNotification.data.data[seriesval1[0]] !== undefined &&
      measurementNotification.data.data[seriesval1[0]][seriesval1[1]] !== undefined
    ) {
      const measurementValue =
        measurementNotification.data.data[seriesval1[0]][seriesval1[1]].value;
      if (measurementValue) {
        console.log(
          'would call setValuesToChart with',
          selectedSeriesWithType,
          measurementValue
        );
      }
    }
  } catch (e) {
    console.log('Advanced Radial Gauge Widget - ' + e);
  }
});

And I got these logs in the console:

{channel: '/measurements/6201', id: '107748', data: {…}}
would call setValuesToChart with c8y_Temperature.T 8.0901699437
{channel: '/measurements/6201', id: '108104', data: {…}}
would call setValuesToChart with c8y_Temperature.T 9.1354545764
{channel: '/measurements/6201', id: '108517', data: {…}}
would call setValuesToChart with c8y_Temperature.T 9.7814760073
{channel: '/measurements/6201', id: '108955', data: {…}}
would call setValuesToChart with c8y_Temperature.T 10
{channel: '/measurements/6201', id: '109371', data: {…}}
{channel: '/measurements/6201', id: '109781', data: {…}}
{channel: '/measurements/6201', id: '110287', data: {…}}
{channel: '/measurements/6201', id: '110798', data: {…}}
{channel: '/measurements/6201', id: '111321', data: {…}}
would call setValuesToChart with c8y_Temperature.T 5
{channel: '/measurements/6201', id: '111757', data: {…}}
would call setValuesToChart with c8y_Temperature.T 3.0901699437
{channel: '/measurements/6201', id: '112121', data: {…}}
would call setValuesToChart with c8y_Temperature.T 1.0452846327
{channel: '/measurements/6201', id: '112507', data: {…}}
would call setValuesToChart with c8y_Temperature.T -1.0452846327
{channel: '/measurements/6201', id: '112879', data: {…}}
would call setValuesToChart with c8y_Temperature.T -3.0901699437

As you can see not every incoming measurementNotification was eventually passed to setValuesToChart and it was because there were other measurements sent than c8y_Temperature.T and they did not pass the checks.
Does your device also send different types of measurements than the one you try to capture with this code?
Do you observe similar effect on your side? Or does it behave differently for you, e.g. it stops receiving any measurement notifications after some time?
You mentioned “sometime receive in Realtime Observable and sometimes not receive” - does it mean that despite device continuosuly sending measurements, you get no callback calls from subscribe for some time, as if it pauses to receive any notifications? If so, how long these pauses are? How many notifications are lost approximately during such a break? How often do these breaks happen? Are they random? Or is there any pattern?

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.