MQTT multiple subscribers to one topic not working

0

I've recently started using the MQTT broker in AWS, where one device receives messages to control a wind turbine. Now, I wanted to expand this control by connecting a second device to the broker topic. However, I've noticed that when two devices are connected, they seem to constantly 'fight' for connection, pushing each other off. I thought MQTT could support multiple subscribers? When I turn off one of the devices, everything works as expected.

已提问 1 个月前82 查看次数
1 回答
2

Hi,

The error you are seeing is indicative of using the same MQTT clientId for both connections. This is covered here:

If you are connecting to AWS IoT using MQTT, each of your connections must be associated with an identifier known as a client ID. MQTT client IDs uniquely identify MQTT connections. If a new connection is established using a client ID that is already claimed for another connection, the AWS IoT message broker drops the old connection to allow the new connection.

Changing the clientId to be unique should resolve that. Also make sure that the AWS IoT Policy allows for the clientId's you wish to present. It's a best practice to only allow a clientId that matches a thingName associated with the X.509 certificate, so that may need to be changed too.

AWS
Gavin_A
已回答 1 个月前
profile pictureAWS
专家
已审核 25 天前
  • Hello, I'm sending data to multiple devices. Is this the same issue? How do I change the client ID? Are they unable to subscribe to the same topic?

  • Sending messages to multiple devices would be another pattern. In that case the devices can subscribe to a common topic such as cmd/request, and then the process sending the message can publish to that same topic and all subscribers will receive the message. This whitepaper goes into full detail.

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

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

回答问题的准则

相关内容