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.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ