Skip to content

MqttClient: Somehow got message from topic that no one subscribed to

0

In my scenario i deployed 3 components provided by aws : stream manager, token auth service, device defender and a custom component that does data push to stream manager. in my case i got this error among greengrass logs and it seems to me related to what device defender pushes on this topic : MqttClient: Somehow got message from topic that no one subscribed to. {clientId=edge-one, topic=$aws/things/edge-one/defender/metric s/json/accepted. The thing to which it is hooked has both publish and subscribe permissions to all topics : arn:aws:iot:${AWS::Region}:${AWS::AccountId}:topic/$aws/things/${thingName}/defender/*

How can I solve this error ?

1 Answer
0
Accepted Answer

Hi. The Device Defender component should subscribe to that topic. You should see something like this in the Device Defender component logs:

2024-05-30T11:13:04.047Z [INFO] (Copier) aws.greengrass.DeviceDefender: stdout. Subscribed to topic $aws/things/GreengrassEC2DeviceFarm-ubuntu-20-04-x86-64/defender/metrics/json/accepted.{scriptName=services.aws.greengrass.DeviceDefender.lifecycle.run.script, serviceName=aws.greengrass.DeviceDefender, currentState=RUNNING}
2024-05-30T11:13:04.055Z [INFO] (Copier) aws.greengrass.DeviceDefender: stdout. Subscribed to topic $aws/things/GreengrassEC2DeviceFarm-ubuntu-20-04-x86-64/defender/metrics/json/rejected.{scriptName=services.aws.greengrass.DeviceDefender.lifecycle.run.script, serviceName=aws.greengrass.DeviceDefender, currentState=RUNNING}

Please confirm that the Device Defender log contains no errors.

The thing to which it is hooked has both publish and subscribe permissions to all topics

You need Publish, Subscribe and Receive. And Subscribe needs a topicfilter resource not topic.

arn:aws:iot:${AWS::Region}:${AWS::AccountId}:topic/$aws/things/${thingName}/defender/*

This isn't the literal string, right? Perhaps share your whole policy.

Also, does greengrass.log have any other errors? You've only given us a very small snippet. Could you perhaps edit the question and give a larger section of the greengrass.log file, particularly if there are other errors or warnings?

AWS
EXPERT

answered 2 years ago

  • Hi, thanks for your answer. I solved it by entering among the get component artifacts resources an ARN that does not refer to a specific account ex (!Sub arn:aws:greengrass:${AWS::Region}::). because it seems that if I enter the specific account id you can't download device defender and then can't subscribe either. For the other policies yes, I put in both subscribe and publish like this:

    • Effect: Allow Action: - iot:Receive - iot:Publish Resource: - !Sub arn:aws:iot:${AWS::Region}:${AWS::AccountId}:topic/$aws/things/${thingName}/* - Effect: Allow Action: - iot:Subscribe Resource: - !Sub arn:aws:iot:${AWS::Region}:${AWS::AccountId}:topicfilter/$aws/things/${thingName}/* - !Sub arn:aws:iot:${AWS::Region}:${AWS::AccountId}:topic/$aws/things/${thingName}/*

    Anyway it works now

  • I'm glad it's working, but I'm a little puzzled because ${thingName} is not valid: https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html

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.