如何将 aws_iot_device_sdk_v2 集成到 webpack/react 应用程序中?

问题描述

我正在尝试将 aws-iot-device-sdk-js-v2 集成到使用 webpack (jitsi-meet-electron) 的电子应用程序中,但我不明白为什么会出现此错误

Uncaught (in promise) TypeError: aws_iot_device_sdk_v2__WEBPACK_IMPORTED_MODULE_10__.iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path is not a function
    at createConnection (Conference.js:369)
    at Conference._onVideoConferenceJoined (Conference.js:316)
    at D.eval (Conference.js:182)
    at D.a.emit (external_api.js:265)
    at eval (external_api.js:1259)
    at eval (external_api.js:891)
    at Set.forEach (<anonymous>)
    at _.emit (external_api.js:890)
    at _onMessageReceived (external_api.js:879)
    at eval (external_api.js:836)

我在 Conference.js (https://github.com/jitsi/jitsi-meet-electron/blob/master/app/features/conference/components/Conference.js) 中创建了一个新的异步函数

async function createConnection(id: string) {

    const client_bootstrap = new io.ClientBootstrap();
    let config_builder = null;
    config_builder = iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path(
        "/path/to/certificate.pem.crt.txt","/path/to/private.pem.key");
    config_builder.with_certificate_authority_from_path(
        undefined,"/path/to/AmazonRootCA1.pem");
    config_builder.with_clean_session(false);
    config_builder.with_client_id(id);
    config_builder.with_endpoint("<my_prefix>-ats.iot.<my_region>.amazonaws.com");

    const config = config_builder.build();
    const client = new mqtt.MqttClient(client_bootstrap);
    const connection = client.new_connection(config);

    await connection.connect()
    await sconnection.disconnect()
}

我错过了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)