Go paho IoT Core mqtt 客户端的问题

0

【以下的问题经过翻译处理】 我编写了一个简单的IoT Core客户端,尝试使用基本摄取来推送消息。客户端是用go编写的。它能够连接成功,但是当我尝试发送消息时,我遇到了以下问题:

{      "timestamp": "2022-11-14 21:56:42.078",      "logLevel": "ERROR",      "traceId": "22dd3237-1e62-6fde-fd45-d796ca4e4a2b",      "accountId": "xxxx",      "status": "Failure",      "eventType": "Publish-In",      "protocol": "MQTT",      "topicName": "$aws/rules/stat",      "clientId": "washnet-test-1",      "principalId": "xxxx",      "sourceIp": "xxx.xxx.xxx.xxx",      "sourcePort": 47410 }

我不确定这意味着什么。该代码使用MQTT版本3.1.1和QOS级别0进行发布。

status := StatusMessage{ Status: "OK", } payload, err := json.Marshal(status) if err != nil { panic(err) } token := mqttClient.Publish("$aws/rules/stat", byte(0), true, payload) token.Wait()

这是使用[客户端v1.4.2](github.com/eclipse/paho.mqtt.golang)的情况。客户端响应: [DEBUG] [client] enter Publish [DEBUG] [client] sending publish message, topic: $aws/rules/stat [DEBUG] [net] obound msg to write 0 [DEBUG] [net] obound wrote msg, id: 0 [DEBUG] [net] outgoing waiting for an outbound message 2022/11/14 16:56:42 [OK] Message sent 2022/11/14 16:56:42 Sleeping [DEBUG] [net] incoming complete [DEBUG] [net] startIncomingComms: got msg on ibound [DEBUG] [net] logic waiting for msg on ibound [DEBUG] [net] startIncomingComms: ibound complete [DEBUG] [net] startIncomingComms goroutine complete [DEBUG] [net] outgoing waiting for an outbound message [ERROR] [client] Connect comms goroutine - error triggered EOF [DEBUG] [client] internalConnLost called

profile picture
专家
已提问 5 个月前14 查看次数
1 回答
0

【以下的回答经过翻译处理】 我讨厌在发布问题几分钟之后又想出答案。

问题出在我最初将qos设置为2,然后将retain设置为true。当我将qos设置为0并将retain设置为false时,它触发了我的规则。

我理解为什么设置qos=2会出问题。但我不理解为什么设置retain=true也会,当我查看这篇文档这篇文档时,它们给我留下的印象是retain=true应该可以工作。

难道retain=true不能与基本摄取一起工作吗?这似乎是有道理的,因为沿着基本摄取主题发送的内容更像是一条流而不是您想要持久化的单个状态。

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则