Skip to content

How to publish to the basic ingest topic using the greengrass sdk

0

I am trying to use the greengrass IPC client sdk for js. To send a message to the basic ingest topic.

await this.ipcClient.publishToIoTCore({
					topicName: `$aws/rules/${basicIngestRule}/${this.thingName}/${topic}`,
					qos,
					payload: publishMessage,
					retain,
				});

I get the error in the greengrass logs

2025-06-04T05:45:01.660Z [ERROR] (AwsEventLoop 1) com.aws.greengrass.mqttclient.MqttClient: Failed to publish the message via Spooler and will retry. {reason=PUBACK:Topic can't start with $:c94e9e14-288a-99ed-35a0-6ffd767d695a, reasonCode=144}
2025-06-04T05:45:01.946Z [INFO] (AwsEventLoop 1) com.aws.greengrass.mqttclient.MqttClient: Publishing message got a non-retryable reason code, not retrying. {reason=PUBACK:Topic can't start with $:edd5b852-7d60-0336-048c-ccf89ba2bb3d, topic=$aws/rules1/alertMessageIoTRule/100000004215d806/alerts/engine/1/fuelRate, reasonCode=144}

How do you publish directly to the basic ingest topic?

asked a year ago181 views

2 Answers
1

It appears that you're encountering an issue when trying to publish to a topic that starts with "It appears that you're encountering an issue when trying to publish to a topic that starts with "$" using the AWS IoT Greengrass SDK. The error message suggests that topics starting with "$" are not allowed for direct publishing.

To publish to the basic ingest topic for AWS IoT Core rules, you should not include the "$aws/rules/" prefix in your topic name when using the Greengrass SDK. Instead, you should publish to the topic without this prefix.

Try modifying your code to remove the "$aws/rules/" part from the topic name:

await this.ipcClient.publishToIoTCore({
    topicName: `${basicIngestRule}/${this.thingName}/${topic}`,
    qos,
    payload: publishMessage,
    retain,
});

This should allow you to publish to the intended topic without encountering the error about topics starting with "$".

Remember that the AWS IoT Core rules engine will still process messages published to this topic as if they were published to the full basic ingest topic (including the "$aws/rules/" prefix). The Greengrass core handles the routing of these messages to the appropriate AWS IoT Core topic behind the scenes.

If you're still experiencing issues, make sure that your Greengrass component has the necessary permissions to publish to IoT Core topics. You may need to check your component's authorization policy to ensure it has the correct permissions for the "aws.greengrass#PublishToIoTCore" operation.quot; using the AWS IoT Greengrass SDK. The error message suggests that topics starting with "It appears that you're encountering an issue when trying to publish to a topic that starts with "$" using the AWS IoT Greengrass SDK. The error message suggests that topics starting with "$" are not allowed for direct publishing.

To publish to the basic ingest topic for AWS IoT Core rules, you should not include the "$aws/rules/" prefix in your topic name when using the Greengrass SDK. Instead, you should publish to the topic without this prefix.

Try modifying your code to remove the "$aws/rules/" part from the topic name:

await this.ipcClient.publishToIoTCore({
    topicName: `${basicIngestRule}/${this.thingName}/${topic}`,
    qos,
    payload: publishMessage,
    retain,
});

This should allow you to publish to the intended topic without encountering the error about topics starting with "$".

Remember that the AWS IoT Core rules engine will still process messages published to this topic as if they were published to the full basic ingest topic (including the "$aws/rules/" prefix). The Greengrass core handles the routing of these messages to the appropriate AWS IoT Core topic behind the scenes.

If you're still experiencing issues, make sure that your Greengrass component has the necessary permissions to publish to IoT Core topics. You may need to check your component's authorization policy to ensure it has the correct permissions for the "aws.greengrass#PublishToIoTCore" operation.quot; are not allowed for direct publishing.

To publish to the basic ingest topic for AWS IoT Core rules, you should not include the "$aws/rules/" prefix in your topic name when using the Greengrass SDK. Instead, you should publish to the topic without this prefix.

Try modifying your code to remove the "$aws/rules/" part from the topic name:

await this.ipcClient.publishToIoTCore({
topicName: `${basicIngestRule}/${this.thingName}/${topic}`,
qos,
payload: publishMessage,
retain,
});

This should allow you to publish to the intended topic without encountering the error about topics starting with "It appears that you're encountering an issue when trying to publish to a topic that starts with "$" using the AWS IoT Greengrass SDK. The error message suggests that topics starting with "$" are not allowed for direct publishing.

To publish to the basic ingest topic for AWS IoT Core rules, you should not include the "$aws/rules/" prefix in your topic name when using the Greengrass SDK. Instead, you should publish to the topic without this prefix.

Try modifying your code to remove the "$aws/rules/" part from the topic name:

await this.ipcClient.publishToIoTCore({
    topicName: `${basicIngestRule}/${this.thingName}/${topic}`,
    qos,
    payload: publishMessage,
    retain,
});

This should allow you to publish to the intended topic without encountering the error about topics starting with "$".

Remember that the AWS IoT Core rules engine will still process messages published to this topic as if they were published to the full basic ingest topic (including the "$aws/rules/" prefix). The Greengrass core handles the routing of these messages to the appropriate AWS IoT Core topic behind the scenes.

If you're still experiencing issues, make sure that your Greengrass component has the necessary permissions to publish to IoT Core topics. You may need to check your component's authorization policy to ensure it has the correct permissions for the "aws.greengrass#PublishToIoTCore" operation.quot;.

Remember that the AWS IoT Core rules engine will still process messages published to this topic as if they were published to the full basic ingest topic (including the "$aws/rules/" prefix). The Greengrass core handles the routing of these messages to the appropriate AWS IoT Core topic behind the scenes.

If you're still experiencing issues, make sure that your Greengrass component has the necessary permissions to publish to IoT Core topics. You may need to check your component's authorization policy to ensure it has the correct permissions for the "aws.greengrass#PublishToIoTCore" operation.
Sources
Publish/subscribe AWS IoT Core MQTT messages - AWS IoT Greengrass
Publish/subscribe local messages - AWS IoT Greengrass

answered a year ago

EXPERT

reviewed a year ago

  • I want to confirm that if following these instructions do you still get the benefit of the basic ingest topic and not incurring normal message charges? Can you please point to the documentation on this?

    Testing it in the console I can publish to the topic of $aws/rules/.... and it works as intended. when I publish to ${basicIngestRule}/${this.thingName}/${topic} it does not trigger my rule

0

Hi, We have some examples to refer in this document: https://docs.aws.amazon.com/greengrass/v2/developerguide/ipc-iot-core-mqtt.html, an important configuration you should configure in your deployment is accessControl May we confirm we've already configured that and the operation "aws.greengrass#PublishToIoTCore", "aws.greengrass#SubscribeToIoTCore" is ToIoTCore

If this still doesn't work, could you provide full logs and mask the sensitive data please?

Thanks

AWS

answered a year ago

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.