AWS IoT Javascript SDK无法创建客户端

时间:2019-04-03 13:40:24

标签: javascript aws-iot

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

1 个答案:

答案 0 :(得分:1)

process.nextTick中的

Webpacks implementation不接受回调参数。只需在您的main.ts中覆盖它即可!

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

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