首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nuxt + IOT (AWS-物联网-设备-sdk)

Nuxt + IOT (AWS-物联网-设备-sdk)
EN

Stack Overflow用户
提问于 2018-04-16 12:24:02
回答 2查看 320关注 0票数 1

我创建了这样一个插件:

代码语言:javascript
复制
var awsIot = require('aws-iot-device-sdk')
var device = awsIot.device({
  keyPath: 'xxxxxx,
  certPath: 'xxxxxx,
  caPath: 'xxxxxx',
  clientId: 'xxxxx', 
  region: 'xxxxxx',
  host: 'xxxxxxxxxx.amazonaws.com'
})

它可以工作,但显示一条错误消息:

C:\Sistemas\AM\nodemodules\aws-iot-device-sdk\common\lib\tls-reader.js:89 Uncaught : filesys.existsSync不是webpackJsonp../nodemodules/aws-iot-device-sdk/common/lib/tls-reader.js.module.exports的一个函数

我怎么才能解决这个问题?

EN

回答 2

Stack Overflow用户

发布于 2019-05-16 04:58:26

造成这一错误的原因有两个,即,

  1. 角版>4或否及
  2. JsonP中的缩进对齐问题
代码语言:javascript
复制
var awsIot = require('aws-iot-device-sdk');

var device = awsIot.device({
    endpoint: 'https://******************.iot.eu-central-1.amazonaws.com',
    keyPath: '../aws/************-private.pem.key',
    certPath: '../aws/***********-certificate.pem.crt',
    caPath: '../aws/***********-public.pem.key',
    clientId: "******************",
    region: "******" 
});
票数 0
EN

Stack Overflow用户

发布于 2020-01-05 01:12:41

代码语言:javascript
复制
var awsIot = require('aws-iot-device-sdk');
 
//
// Replace the values of '<YourUniqueClientIdentifier>' and '<YourCustomEndpoint>'
// with a unique client identifier and custom host endpoint provided in AWS IoT.
// NOTE: client identifiers must be unique within your AWS account; if a client attempts 
// to connect with a client identifier which is already in use, the existing 
// connection will be terminated.
//
var device = awsIot.device({
   keyPath: 'xxxxxxxxx-private.pem.key',
  certPath: 'xxxxxxxxx-certificate.pem.crt',
    caPath: 'rootCA.pem',
  clientId: 'MyConnect',
   host: 'xxxxxxx.iot.ap-southeast-1.amazonaws.com'
});
 
//
// Device is an instance returned by mqtt.Client(), see mqtt.js for full
// documentation.
//
device
  .on('connect', function() {
    console.log('connect');
    //device.subscribe('topic_1');
    device.publish('MyConnectPolicy', JSON.stringify({ test_data: 'NodeJS server connected...'}));
  });
 
device`enter code here`
  .on('message', function(topic, payload) {
    console.log('message', topic, payload.toString());
  });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49857300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档