您好,我尝试从AWS IoT接收消息。对于发布,我使用php-sdk
use Aws\IotDataPlane\IotDataPlaneClient
$connectionParams = [
'version' => 'latest',
'region' => $region,
'credentials' => [
'key' => $key,
'secret' => $secret,
]
];
$this->client = new IotDataPlaneClient($connectionParams);
$this->client->publish([
"payload" => $message,
'qos' => 1,
'topic' => $topic,
]);
但是我没有任何接收方法。有人知道如何连接和接收消息吗?
答案 0 :(得分:0)
您需要订阅MQTT主题。您有几种选择。
接收消息的Lambda看起来像这样,其中事件是入站MQTT消息
const AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const id = event.id;
const chan0 = event.chan0;
}