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

posta 3 anni fa496 visualizzazioni
4 Risposte
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
ESPERTO
con risposta 3 anni fa
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
con risposta 3 anni fa
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
ESPERTO
con risposta 3 anni fa
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

con risposta 3 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande