gpt4 book ai didi

javascript - AWS IoT Javascript SDK 无法创建客户端

转载 作者:行者123 更新时间:2023-11-30 19:40:03 28 4
gpt4 key购买 nike

我正在使用 Vue.js、TypeScript 和 aws-iot-device-sdk 包,并且喜欢订阅 IoT 主题。这就是我创建新客户端的方式:

import AwsIot from 'aws-iot-device-sdk';
import { config } from 'aws-sdk';

client = new AwsIot.device({
region: 'foo',
host: 'foo',
clientId: 'foo',
protocol: 'wss',
accessKeyId: config.credentials.accessKeyId,
secretKey: config.credentials.secretAccessKey,
sessionToken: config.credentials.sessionToken
});

一秒钟后,我收到此控制台错误:

Uncaught TypeError: Cannot read property 'read' of undefined
at nReadingNextTick (_stream_readable.js)
Uncaught TypeError: Cannot read property 'length' of undefined
at onwriteDrain (_stream_writable.js)
at afterWrite (_stream_writable.js)
Uncaught TypeError: Cannot read property 'length' of undefined
at onwriteDrain (_stream_writable.js)
at afterWrite (_stream_writable.js)
Uncaught TypeError: Cannot read property '_readableState' of undefined
at emitReadable_ (_stream_readable.js)
Uncaught TypeError: Cannot read property 'reading' of undefined
at maybeReadMore_ (_stream_readable.js)

最佳答案

node-libs-browser process.nextTick 的实现不接受回调参数。只需在您的 main.ts 中覆盖它即可!

process.nextTick = function(callback) {
const args = [...arguments];

args.shift();
setTimeout(() => callback.apply(null, args));
}

更新:

已在 v2.2.1 中修复:Commit

关于javascript - AWS IoT Javascript SDK 无法创建客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55496627/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com