Publish MQTT from Lambda C++

0

Hi,

I developed a Lambda in C++ that publishes messages to MQTT using the IoTDataPlaneClient, however it takes 1 full second to send the first message, any subsequent messages (within the same request) take about 10 ms. Is there any way to improve the speed of this first message?

已提問 1 年前檢視次數 276 次
1 個回答
0

Hi,

For IoTDataPlaneClient within Lambda, if Lambda's are being reused, moving the instantiation of client outside of the main event handler can reduce subsequent calls. Then if the same Lambda is called again, that client can be reused.

What I haven't investigated is how the underlying client managed state, and if those parameters can be adjusted. The data plane client is making HTTP POSTs for the different operations such as Publish, so creating an HTTP persistent connection could be an approach to keep a connection pool open. Not a C++ expert, but I found this example that may help.

AWS
Gavin_A
已回答 1 年前
  • Thanks for the reply,

    Would there be a way to maintain the connection across Lambda invocations?

  • Apologies, I misread this as a full MQTT connection (when I definitely saw the reference to IoTDataPlaneClient too! :) ). I've updated my answer with guidance on that.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南