物联网发布失败

时间:2019-03-03 13:20:09

标签: amazon-web-services mqtt esp32

我正在尝试使用我自己的MQTT客户端连接到AWS-IoT(因为学习和对以后任务的更多控制)。我可以连接并获得提示信息,但是当我尝试发布时,连接关闭。

我已经启用CloudWatch并收到以下事件:

{
"timestamp": "2019-03-03 11:41:26.629",
"logLevel": "INFO",
...
"status": "Success",
"eventType": "Connect",
"protocol": "MQTT",
"clientId": "ESP32_e839169e",
...
}

{
"timestamp": "2019-03-03 11:41:57.065",
"logLevel": "ERROR",
...
"status": "Failure",
"eventType": "Publish-In",
"protocol": "MQTT",
"topicName": "a/b",
"clientId": "ESP32_e839169e",
...
}

{
"timestamp": "2019-03-03 11:41:57.073",
"logLevel": "INFO",
...
"status": "Success",
"eventType": "Disconnect",
"protocol": "MQTT",
"clientId": "ESP32_e839169e",
...
}

(我没有发送断开连接,它来自aws)

我的策略文档不应该是问题,因为我得到了带有相同证书文件的basicPubSub-Example。这是我的政策文件:

{
"Version": "2012-10-17",
"Statement": [
    {
    "Effect": "Allow",
    "Action": [
        "iot:Publish",
        "iot:Subscribe",
        "iot:Connect",
        "iot:Receive"
        ],
    "Resource": [
        "*"
        ]
    },
    {
    "Effect": "Allow",
    "Action": [
        "greengrass:*"
        ],
    "Resource": [
        "*"
        ]
    }
]
}

因为我使用自己的MQTT客户端,所以不能完全保证我的消息完全正确。

这是我的消息:

Byte -  Hex - Char - Meaning

   0 - 0x30 - 0    - message type, flags -> Publish, dub = false, qos = QOS0, retain = false
   1 - 0x13 -      - message length      -> 19 Bytes
   2 - 0x00 -      - topic length        ->  3 Bytes
   3 - 0x03 - ╚
   4 - 0x61 - a    - topic               -> a/b
   5 - 0x2f - /
   6 - 0x62 - b
   7 - 0x00 -      - packed identifier   -> 0
   8 - 0x00 -  
   9 - 0x74 - t    - payload             -> test_payload
  10 - 0x65 - e
  11 - 0x73 - s
  12 - 0x74 - t
  13 - 0x5f - _
  14 - 0x70 - p
  15 - 0x61 - a
  16 - 0x79 - y
  17 - 0x6c - l
  18 - 0x6f - o
  19 - 0x61 - a
  20 - 0x64 - d

我在做什么错?有没有办法从aws获取更多信息,这是什么问题?

0 个答案:

没有答案