错误:此套接字已由另一部分结束

时间:2019-07-11 10:14:27

标签: aws-sdk iot aws-iot

我正在尝试设置aws-iot-device-sdk

所以我尝试了很多谷歌搜索,并尝试在本地设置服务器以对其进行测试。

const awsIot = require("aws-iot-device-sdk");
const certs = require("./config");

let device = awsIot.device({
  keyPath: certs.KEYPATH,
  certPath: certs.CERTPATH,
  caPath: certs.CAPATH,
  clientId: "rt.bottle.com.np",
  host: "aot2wgmcbqwsa-ats.iot.ap-south-1.amazonaws.com",
  region: "ap-south-1"
});

device.on("connect", function() {
  console.log("connected");
  let data = {
    id: "ID-2D886176CBD2",
    name: "RT_DEVICE6",
    activated: true,
    serial: 6
  };
  setInterval(() => {
    device.publish(
      "rt_device/ID-2D886176CBD2/info",
      JSON.stringify({ test_data: data })
    );
  }, 15000);
});

device.on("message", function(topic, payload) {
  console.log("message", topic, payload.toString());
});

在接收到3-5次数据之后,服务器继续崩溃。 它一直没有崩溃,并一直接收数据,直到它停止为止。我目前正在使用aws控制台iot来执行此操作,而这种行为即将来临。

0 个答案:

没有答案