MQTT connection via WebSocket with aws-iot-device-sdk-cpp-v2 (v1.31.0) #687
-
Hi, We are developing an IoT solution with the aws-iot-device-sdk-cpp-v2 library. Our devices run an Embedded Linux OS with a user-space application written in C++ (C runtime is uclibc, ARM CPU). This application links with the AWS SDKs (*.so libraris):
We have been trying to implement a MQTT connection based on Websocket with no luck. Normal connection (TCP socket, port 8883) works with no issues but when trying to run our implementation of a Websocket connection (port 443) - We get an error. Our devices hold 3 "secret files" to allow the application to connect to IoT Core (created using IoT Core APIs):
These secrets allow the device to: All of the above are working fine. In addition to (a), we would also like to be able to connect to the WSS endpoint (port 443). The follwing code is taken from the following examples: Websocket connection example and X509 auth provider example To implement a WSS connection, we create a
The
The X509 credentials provider created is then used to configure the MQTT over WSS connection:
My understanding is that the X509 credentials provider that was created will be using the secret files to fetch temporary AWS credentials when the connection is establshed (and will refresh these credentials when they expire). Please correct me if I'm wrong here. The above code compiles but when executed - the MQTT over WSS connection fails, that is, the connection callback is called with an error:
Please direct us to a proper solution to establish a MQTT over WSS connection to IoT Core. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
There may be other issues, but the X509 credentials endpoint and the MQTT broker endpoint are not the same and your code appears to be using the same value for both. Using the aws cli:
vs.
|
Beta Was this translation helpful? Give feedback.
-
Hi Bret and thanks for spotting the usage of the incorrect enpoint when the provider is created. It definitly makes sense now with you comment. Case IUsing the string as is (
Case IIUsing this string:
I have a feeling we are very close and an additional push will be very helpful. Thanks again, Omri |
Beta Was this translation helpful? Give feedback.
Hi @bretambrose ,
We managed to establish a MQTT over WSS connection successfully.
It was indeed a policy configuration of the role alias our devices assume.
I belive it should be better expressed in the documentation.
Thanks again for directing us to a solution.
Omri