Greengrass v2 IPC subscriptions

0

Hi. I'm writing some lambdas to run in greengrass v2. I have several energy monitoring systems running AWS Freertos and publishing to GG. According to https://docs.aws.amazon.com/greengrass/v2/developerguide/ipc-publish-subscribe.html#ipc-operation-subscribetotopic , in component aws.greengrass.ipc.pubsub (operation aws.greengrass#SubscribeToTopic) "This topic string doesn't support MQTT topic wildcards (# and +).". I didn't understood why. The component aws.greengrass.ipc.mqttproxy supports without problem. Can anyone explain me how make my subscriptions more general? Thanks in advance.

1 Answer
0

Hello,

MQTT wildcards are indeed supported when subscribing to a MQTT topic. The topic which you subscribe to must be a subset of the allowed topics which are listed in the "resources" section of the access control policy.

I will work to get this clarified in the documentation.

For example: If you are allowed to subscribe to a/b/+/d in the resources section of the access control policy, then you may subscribe using the IPC call to a/b/c/d, a/b/e/d, or a/b/+/d.

You may also use * in the resources section to allow subscribing to any topic.

Edit clarification:

Local PubSub is a different set of APIs; local pubsub is not MQTT, and thus it does not support MQTT-style wildcards.

If you wish to allow publishing and subscribing for local pubsub topics without specifying each topic individually, then you should use the wildcard *

AWS
EXPERT
answered 2 years ago
  • Hi, Michael. Thanks for the fast response. But I tried, and this doesn't works for aws.greengrass.ipc.pubsub. In my component configuration I use (just like explained in documentation): accessControl: aws.greengrass.ipc.pubsub: com.simemap.GG-EMU-pg-db-insert:pubsub:1: operations: - "aws.greengrass#PublishToTopic" - "aws.greengrass#SubscribeToTopic" policyDescription: "Allows access to publish/subscribe to all topics." resources: - "*"

    In my code: (not working) topic = "Simemap/POC/1/1/+/eletric/data" request = SubscribeToTopicRequest() request.topic = topic request.qos = QOS.AT_MOST_ONCE handler = StreamHandler() operation = ipc_client.new_subscribe_to_topic(handler) future = operation.activate(request)

    However, if I use topic = "Simemap/POC/1/1/POC_2/eletric/data"

    works fine. I confirm wildcards works well for aws.greengrass.ipc.mqttproxy. But not for aws.greengrass.ipc.pubsub.

  • Hello, as I said, local pubsub (subscribe to topic) is not the same as MQTT, therefore it does not use MQTT wildcards. You can subscribe to a topic called a/b/+/c, but that is subscribing to literally a topic called a/b/+/c, it doesn't subscribe with a wildcard. Wildcard subscriptions are not supported in anyway for local pubsub, you must subscribe to the specific topic.

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