【问题标题】:AWS IoT Javascript SDK can not create clientAWS IoT Javascript SDK 无法创建客户端
【发布时间】:2019-06-17 17:30:37
【问题描述】:

我正在使用 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)

【问题讨论】:

    标签: javascript aws-iot


    【解决方案1】:

    node-libs-browserprocess.nextTick 实现不接受回调参数。只需在 main.ts 中覆盖它!

    process.nextTick = function(callback) {
        const args = [...arguments];
    
        args.shift();
        setTimeout(() => callback.apply(null, args));
    }
    

    更新:

    在 v2.2.1 中已修复:Commit

    【讨论】:

      猜你喜欢
      • 2022-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      • 1970-01-01
      • 1970-01-01
      • 2019-02-11
      • 2023-03-12
      相关资源
      最近更新 更多