Greengrass StreamManager unable to connect to IoTAnalytics

356 views Asked by At

I'm quite new to AWS and Greengrass v2 and step by step I seem to get the hang of it. But now I'm stuck and I wanted to ask this question here:

  • I have a functioning Greengrass Core device installed using the --provision true option, so the Role and Alias is automatically generated by the installer
  • I'm able to send messages to IoTCore and back
  • I'm able to trigger Lambda functions based on a specific topic
  • I'm running following AWS provided components:
    • Nucleus
    • ShadowManager
    • StreamManager
    • TokenExchangeService
    • clientdevices.Auth
    • clientdevices.mqtt.Bridge
    • clientdevices.mqtt.Moquette
  • To the IAM Role I added the Policy to be able to push data to IoTAnalytics
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iotanalytics:BatchPutMessage"
      ],
      "Resource": [
        "arn:aws:iotanalytics:region:account-id:channel/channel_1_name",
        "arn:aws:iotanalytics:region:account-id:channel/channel_2_name"
      ]
    }
  ]
}

I created a custom component

This component is capable of:

  • Connect to the StreamManager
  • Create a stream on the StreamManager
  • Append messages to the created stream every 10 seconds

These are the log files of the component and all seem well:

2022-03-04T08:30:37.710Z [INFO] (Copier) eu.grnrg.Weather: stdout. Opening connection to 127.0.0.1:8088. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:37.961Z [INFO] (Copier) eu.grnrg.Weather: stdout. Received ConnectResponse from server: ConnectResponse {}. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:37.962Z [INFO] (Copier) eu.grnrg.Weather: stdout. Successfully connected. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.095Z [INFO] (Copier) eu.grnrg.Weather: stdout. Received DeleteMessageStreamResponse from server MessageFrame {}. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.313Z [INFO] (Copier) eu.grnrg.Weather: stdout. Received CreateMessageStreamResponse from server MessageFrame {}. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.314Z [INFO] (Copier) eu.grnrg.Weather: stdout. Trying yo append a message to the stream. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.389Z [INFO] (Copier) eu.grnrg.Weather: stdout. Received AppendMessageResponse from server MessageFrame {}. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.390Z [INFO] (Copier) eu.grnrg.Weather: stdout. Successfully appended message to stream with sequence number 0. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.413Z [INFO] (Copier) eu.grnrg.Weather: stdout. Received AppendMessageResponse from server MessageFrame {}. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.414Z [INFO] (Copier) eu.grnrg.Weather: stdout. Successfully appended message to stream with sequence number 1. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}
2022-03-04T08:30:38.560Z [INFO] (Copier) eu.grnrg.Weather: stdout. Received ReadMessagesResponse from server. {scriptName=services.eu.grnrg.Weather.lifecycle.Run, serviceName=eu.grnrg.Weather, currentState=RUNNING}

StreamManager updates

But the StreamManager seems to give an error when it tries to upload the data to IoTAnalytics. These are the error logs from aws.greengrass.StreamManager.log From what I can read the StreamManager seems to be unable to get the AWS credentials from Greengrass

2022-03-04T08:21:44.743Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. 2022 Mar 04 08:21:44,732 [ERROR] (pool-7-thread-5) com.amazonaws.iot.greengrass.streammanager.export.upload.MessageUploaderTask: Encountered Throwable when exporting messages. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.744Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. com.amazonaws.iot.greengrass.streammanager.exceptions.ExportDestinationException: Encountered error while exporting data to AWS IoT Analytics: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path., com.amazonaws.auth.profile.ProfileCredentialsProvider@dd7cebc: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@113a5012: Bad Request (Service: null; Status Code: 400; Error Code: null; Request ID: null; Proxy: null)]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.744Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.iot.greengrass.streammanager.export.destination.IOTAnalyticsDestination.sendMessage(IOTAnalyticsDestination.java:75) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.744Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.iot.greengrass.streammanager.export.upload.MessageUploaderTask.upload(MessageUploaderTask.java:77) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.745Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) [?:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.745Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.745Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.745Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at java.lang.Thread.run(Thread.java:829) [?:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.745Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. Caused by: com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path., com.amazonaws.auth.profile.ProfileCredentialsProvider@dd7cebc: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@113a5012: Bad Request (Service: null; Status Code: 400; Error Code: null; Request ID: null; Proxy: null)]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.746Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:136) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.746Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1257) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.746Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient$RequestExecutor.runBeforeRequestHandlers(AmazonHttpClient.java:833) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.746Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:783) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.747Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.747Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.748Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.748Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.749Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.749Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.749Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.services.iotanalytics.AWSIoTAnalyticsClient.doInvoke(AWSIoTAnalyticsClient.java:3239) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.750Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.services.iotanalytics.AWSIoTAnalyticsClient.invoke(AWSIoTAnalyticsClient.java:3206) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.750Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.services.iotanalytics.AWSIoTAnalyticsClient.invoke(AWSIoTAnalyticsClient.java:3195) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.751Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.services.iotanalytics.AWSIoTAnalyticsClient.executeBatchPutMessage(AWSIoTAnalyticsClient.java:375) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.752Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.services.iotanalytics.AWSIoTAnalyticsClient.batchPutMessage(AWSIoTAnalyticsClient.java:344) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.753Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. at com.amazonaws.iot.greengrass.streammanager.export.destination.IOTAnalyticsDestination.sendMessage(IOTAnalyticsDestination.java:60) ~[AWSGreengrassGreenlake-1.0-super.jar:?]. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}
2022-03-04T08:21:44.753Z [INFO] (Copier) aws.greengrass.StreamManager: stdout. ... 5 more. {scriptName=services.aws.greengrass.StreamManager.lifecycle.startup.script, serviceName=aws.greengrass.StreamManager, currentState=RUNNING}

For the complete information, these are the full debug logs from the Stream Manager in this gist. The error is at line #167

I hope someone can help me out, so I can get my measurement data out to IoTAnalytics.

Thanks! Regards

Hacor

0

There are 0 answers