0

我对 AWS 和 Greengrass v2 还很陌生,一步一步我似乎掌握了窍门。但现在我被困住了,我想在这里问这个问题:

  • 我使用该--provision true选项安装了一个正常运行的 Greengrass Core 设备,因此安装程序会自动生成角色和别名
  • 我能够向IoTCore发送消息并返回
  • 我能够根据特定主题触发Lambda函数
  • 我正在运行以下 AWS 提供的组件:
    • 影子管理器
    • 流管理器
    • 代币兑换服务
    • 客户端设备.Auth
    • clientdevices.mqtt.Bridge
    • 客户端设备.mqtt.Moquette
  • 我向 IAM 角色添加了能够将数据推送到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"
      ]
    }
  ]
}

我创建了一个自定义组件

该组件能够:

  • 连接到 StreamManager
  • 在 StreamManager 上创建流
  • 每 10 秒将消息附加到创建的流中

这些是组件的日志文件,一切看起来都很好:

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 更新

但是 StreamManager 在尝试将数据上传到IoTAnalytics时似乎会出错。这些是aws.greengrass.StreamManager.log 来自我可以阅读的错误日志 StreamManager 似乎无法从 Greengrass 获取 AWS 凭证

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}

有关完整信息,这些是此要点中 Stream Manager 的完整调试日志。错误在第 167 行

我希望有人可以帮助我,这样我就可以将我的测量数据发送给 IoTAnalytics。

谢谢!问候

哈科尔

4

0 回答 0