Unable to build connection cloud connection in Node.js using aws-iot-device-sdk-js-v2 package #355
-
Using this package() to make connections to the cloud and I am facing an issue while creating a build with the configuration builder. I am using this simple basic connect example to connect (I used it in my application with some changes in the flow of code): So, I modified the flow of starting this execution, I called the below method from my myProject/index.ts: and main() function I have passed this cloud_args: From the main function, I called below build_connection() method: In this method, I have used predefined methods and in the last line: 35, I am getting the below error: I am unable to build the connection using the config_builder using this aws-iot-device-sdk-js-v2 package Can anyone help me with this? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Answer: |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Answer:
I'm not 100% sure this is the issue, but the new_mtls_builder_from_path function needs the file paths to the key and cert files, not the data in the files themselves. I think removing fs.readFileSync from initializeCloud may help, as then you will be passing the file path to the key and cert. If you want to pass the file data directly (using fs.readFileSync or otherwise), then you need to use the new_mtls_builder function.
The same applies for the CA file: you either will need to pass the file path or adjust the function to with_certificate_authority.