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.

asked 6 months ago258 views
1 Answer
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
answered 6 months ago
profile pictureAWS
EXPERT
reviewed 6 months ago
  • 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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions