简体   繁体   English

将 MQTT 消息从 AWS Lambda 发送到我的 IOT 设备

[英]Send MQTT messages from AWS Lambda to my IOT Device

I am using AWS LAMBDA triggered by AWS IOT.我正在使用由 AWS IOT 触发的 AWS LAMBDA。 My IOT device is publishing the message and will trigger AWS Lambda.我的 IOT 设备正在发布消息并将触发 AWS Lambda。 After analyzing the message I need to send the analyzed data back to the IOT device.分析完消息后,我需要将分析后的数据发送回 IOT 设备。 My IOT device has subscribe to the topic and waiting for my message to receive.我的 IOT 设备已订阅该主题并等待我的消息接收。

Point here is I need to send the analyzed data from my lambda function using MQTT protocol .这里的重点是我需要使用MQTT 协议从我的 lambda function 发送分析数据。

I have used boto3 to send the data:我使用 boto3 发送数据:

client = boto3.client('iot-data')
    
response = client.publish(
    topic='test/topic1',
    #note:
    qos=0,
    payload=eventText
) 

But the above code sends the data using HTTP which I don't want.但是上面的代码使用我不想要的 HTTP 发送数据。 I need to use MQTT protocol to send the data.我需要使用 MQTT 协议来发送数据。 Is it possible to send it?可以寄吗? if yes, what is the other method?如果是,另一种方法是什么?

Also, my second doubt is.. even if data is sent using HTTP, it is received by my IoT device waiting to receive a message over MQTT protocol.另外,我的第二个疑问是.. 即使使用 HTTP 发送数据,我的 IoT 设备也会收到它,等待通过 MQTT 协议接收消息。 Is it meant like HTTP is converted to MQTT?这是否意味着 HTTP 已转换为 MQTT? but who did it?但是谁做的?

I have already gone through the How can I publish to a MQTT topic in a Amazon AWS Lambda function?我已经完成了如何在 Amazon AWS Lambda function 中发布到 MQTT 主题? but all used boto3 which uses HTTP.但所有使用的boto3都使用了HTTP。

Thank you in advance.先感谢您。

We can use Amazon MQ Service in Amazon lambda and deal with the MQTT messages.我们可以使用 Amazon lambda 中的 Amazon MQ 服务来处理 MQTT 消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM