Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"data" events are duplicated #11

Open
CleberL opened this issue Oct 17, 2019 · 2 comments
Open

"data" events are duplicated #11

CleberL opened this issue Oct 17, 2019 · 2 comments
Labels
bug Something isn't working priority: low

Comments

@CleberL
Copy link

CleberL commented Oct 17, 2019

When a device publishes data items, the data event is received twice for each publication, with repeated information.

e.g.
{from: '6e5a681b2ae7be40', payload: {sensorId: 2, value: 24}}
{from: '6e5a681b2ae7be40', payload: {sensorId: 2, value: 24}}
{from: '6e5a681b2ae7be40', payload: {sensorId: 1, value: true}}
{from: '6e5a681b2ae7be40', payload: {sensorId: 1, value: true}}

@figueredo
Copy link
Contributor

Can you reproduce this behaviour easily? If so, could you provide the steps to reproduce it (perhaps with a complete sample where this happens)?

@CleberL
Copy link
Author

CleberL commented Oct 18, 2019

Yes, it is easily reproduced, after connecting to the cloud in KNoTCloudWebSocket, simply subscribe to the data event to notice the error.
Here's an example of where the error was noticed:

import KNoTCloudWebSocket from "@cesarbr/knot-cloud-websocket";

const client = new KNoTCloudWebSocket({
  protocol: "wss",
  hostname: "ws.cloud",
  port: 443,
  pathname: "/",
  id: "7d7d6432-4499-406e-80f5-c112ab95f728",
  token: "698d0655441576c4add098c7274fa0b69c50c998"
});

client.on("ready", () => {
  client.getDevices({
    type: "knot:thing"
  });
});

client.on("devices", devicesReceived => {
  console.log(devicesReceived);
});

client.on("data", data => {               //two duplicate events are displayed
  console.log(data);
});

client.on("error", err => {
  console.log(err);
  client.close();
});

client.connect();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: low
Projects
None yet
Development

No branches or pull requests

3 participants