Issue while using local IPC for messaging between two local component

0

publish("test/test",message={"a":1})

def publish(self, topic, message, message_format="json"):
"""Publishes message to a topic of AWS IOT

    Args:  
        topic (string): AWS IoT Core Topic  
        message (dict / string): Message to be published  
        message_format  
    """  

    request = PublishToTopicRequest()  
    request.topic_name = topic  
    publish_message = PublishMessage()  
    if message_format != "json":  
        publish_message.binary_message = BinaryMessage(message=bytes(message, "utf-8"))  
        # publish_message.binary_message.message = bytes(message, "utf-8")  
    else:  
        publish_message.json_message = JsonMessage(message=message)  
        # publish_message.json_message.message = message  

    request.publish_message = publish_message  
    operation = self.ipc_client.new_publish_to_topic()  
    operation.activate(request)  
    future = operation.get_response()  
    future.result(TIMEOUT)  

accessControl permissions are:
com.test.test:pubsub:1:
policyDescription: "Allows communication with other components"
operations:
- "aws.greengrass#PublishToTopic"
resources:
- "test/test"

and Greengrass.log are:

2021-01-06T10:30:13.515Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.RpcServer: New connection code [AWS_ERROR_SUCCESS] for [Id 816, Class ServerConnection, Refs 1](2021-01-06T10:30:13.515Z) - <null>. {}
2021-01-06T10:30:13.515Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: aws.greengrass#GreengrassCoreIPC authenticated identity: com.test.test. {}
2021-01-06T10:30:13.515Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: Connection accepted for com.test.test. {}
2021-01-06T10:30:13.515Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: Sending connect response for com.test.test. {}
2021-01-06T10:30:13.517Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.RpcServer: New connection code [AWS_ERROR_SUCCESS] for [Id 818, Class ServerConnection, Refs 1](2021-01-06T10:30:13.517Z) - <null>. {}
2021-01-06T10:30:13.517Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: aws.greengrass#GreengrassCoreIPC authenticated identity: com.test.test {}
2021-01-06T10:30:13.517Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: Connection accepted for com.test.test. {}
2021-01-06T10:30:13.517Z [INFO] (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: Sending connect response for com.test.test. {}
2021-01-06T10:30:13.518Z [ERROR] (Thread-6) com.aws.greengrass.ipc.common.ExceptionUtil: Unhandled exception in IPC. {}
java.lang.NullPointerException

Edited by: allenkallz on Jan 6, 2021 3:21 AM

已提問 3 年前檢視次數 496 次
4 個答案
0

Hi and thanks for using Greengrass v2.

Is there any additional logging after the NullPointerException? There ought to be a stacktrace which would tells us exactly what the problem is.

Thanks!

Michael Dombrowski.

AWS
專家
已回答 3 年前
0

I think I am also getting same error. Here is the complete stack trace:

2021-01-07T14:31:08.759Z \[INFO] (Thread-17) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: Connection accepted for com.example.IPCExample. {}  
2021-01-07T14:31:08.760Z \[INFO] (Thread-17) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: Sending connect response for com.example.IPCExample. {}  
2021-01-07T14:31:08.760Z \[ERROR] (Thread-17) com.aws.greengrass.ipc.common.ExceptionUtil: Unhandled exception in IPC. {}  
java.lang.NullPointerException  
        at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)  
        at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent.handlePublishToTopicRequest(PubSubIPCEventStreamAgent.java:113)  
        at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent.access$100(PubSubIPCEventStreamAgent.java:44)  
        at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent$PublishToTopicOperationHandler.lambda$handleRequest$0(PubSubIPCEventStreamAgent.java:192)  
        at com.aws.greengrass.ipc.common.ExceptionUtil.translateExceptions(ExceptionUtil.java:33)  
        at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent$PublishToTopicOperationHandler.handleRequest(PubSubIPCEventStreamAgent.java:176)  
        at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent$PublishToTopicOperationHandler.handleRequest(PubSubIPCEventStreamAgent.java:160)  
        at software.amazon.awssdk.eventstreamrpc.OperationContinuationHandler.onContinuationMessage(OperationContinuationHandler.java:271)  
        at software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler.onContinuationMessageShim(ServerConnectionContinuationHandler.java:53)  
  

Edited by: kunupat on Jan 7, 2021 6:46 AM

kunupat
已回答 3 年前
0

Based on that stacktrace, that must mean that the topic is null. Please ensure that you have set a non-null topic name in the publish request.

request.topic = "my/topic/name"

Thanks.
Michael Dombrowski

Edited by: MichaelDombrowski-AWS on Jan 7, 2021 9:08 AM

AWS
專家
已回答 3 年前
0

Hi
Thanks for your reply.

The issue is in AWS IoT Python SDK v2 that for communication with the local component we have to create request instance PublishToTopicRequest that accept topic with-param name "topic"

but when we have to communicate with Cloud then we have to create request instance PublishToIoTTopicRequest and this class accepts topic with-param name topic_name. I have one question why you dont have the same param name at both places. Its confusing

See the param names of both classes in the attachment.
And previously it`s not mentioned in Greengrass v2 documentation.

Edited by: allenkallz on Jan 8, 2021 8:37 AM

已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南