aws-greengrass / aws-greengrass-client-device-auth

Apache License 2.0
2 stars 3 forks source link

feat(uat): implement delivery of received message #345

Closed eschastlivtsev closed 1 year ago

eschastlivtsev commented 1 year ago

Description of changes:

Why is this change necessary:

How was this change tested: Manual run of mqtt-client-control and python client. MQTT connect, subscribe, publish, delivery of received MQTT message and disconnect are successful, other commands are not implemented. Linking and shutdown steps are successful.

Test results: Python Paho client output

client-python-paho.exe python-paho-agent
[DEBUG] 2023-06-26 13:05:23.198 asyncio - Using selector: SelectSelector
[INFO ] 2023-06-26 13:05:23.201 GRPCLib - Initialize gRPC library
[INFO ] 2023-06-26 13:05:23.201 GRPCLink - Making gPRC client connection with 127.0.0.1:47619 as python-paho-agent...
[INFO ] 2023-06-26 13:05:23.363 GRPCLink - Client connection with Control is established, local address is 127.0.0.1
[DEBUG] 2023-06-26 13:05:23.363 grpc._cython.cygrpc - Using AsyncIOEngine.POLLER as I/O engine
[INFO ] 2023-06-26 13:05:23.434 MQTTLib - Initialize Paho MQTT library
[INFO ] 2023-06-26 13:05:23.434 GRPCLink - Handle gRPC requests
[INFO ] 2023-06-26 13:05:23.439 GRPCControlServer - Server awaiting termination
[INFO ] 2023-06-26 13:05:26.498 GRPCControlServer - createMqttConnection: clientId Python_Paho_Client broker a3t8vwpkw3sltg-ats.iot.eu-west-1.amazonaws.com:8883
[INFO ] 2023-06-26 13:05:26.505 MqttConnection - Creating MQTT 5 client with TLS
[INFO ] 2023-06-26 13:05:26.506 MqttConnection - MQTT connection ID 0 connecting...
[DEBUG] 2023-06-26 13:05:26.896 AsyncioHelper - On socket open
[DEBUG] 2023-06-26 13:05:26.897 AsyncioHelper - On socket register write
[DEBUG] 2023-06-26 13:05:26.898 AsyncioHelper - On socket unregister write
[INFO ] 2023-06-26 13:05:27.045 MqttConnection - MQTT connection ID 0 connected, client id Python_Paho_Client
[DEBUG] 2023-06-26 13:05:32.158 GRPCControlServer - Subscription: filter test/topic QoS 0 noLocal 0 retainAsPublished 0 retainHandling 2
[INFO ] 2023-06-26 13:05:32.159 GRPCControlServer - SubscribeMqtt connection_id 0
[DEBUG] 2023-06-26 13:05:32.162 AsyncioHelper - On socket register write
[DEBUG] 2023-06-26 13:05:32.167 AsyncioHelper - On socket unregister write
[DEBUG] 2023-06-26 13:05:32.295 MqttConnection - Subscribed on filters 'test/topic' with QoS 0 no local False retain as published False retain handing 2 with message id 1
[INFO ] 2023-06-26 13:05:37.320 GRPCControlServer - PublishMqtt connection_id 0 topic test/topic retain 0
[DEBUG] 2023-06-26 13:05:37.321 AsyncioHelper - On socket register write
[DEBUG] 2023-06-26 13:05:37.325 AsyncioHelper - On socket unregister write
[DEBUG] 2023-06-26 13:05:37.427 MqttConnection - onMessage message b'Hello World!' from topic 'test/topic'
[INFO ] 2023-06-26 13:05:37.428 GRPCDiscoveryClient - Sending OnReceiveMessage request agent_id 'python-paho-agent' connection_id 0 message b'Hello World!' on topic 'test/topic'
[DEBUG] 2023-06-26 13:05:37.446 MqttConnection - Published on topic 'test/topic' QoS 1 retain 0 with rc 0 message id 2
[INFO ] 2023-06-26 13:05:42.460 GRPCControlServer - UnsubscribeRequest Placeholder TODO
[INFO ] 2023-06-26 13:05:57.476 GRPCControlServer - CloseMqttConnection connection_id 0 reason 4
[INFO ] 2023-06-26 13:05:57.477 MqttConnection - Disconnect MQTT connection with reason code 4
[DEBUG] 2023-06-26 13:05:57.480 AsyncioHelper - On socket register write
[INFO ] 2023-06-26 13:05:57.481 GRPCDiscoveryClient - Sending OnMqttDisconnect request agent_id 'python-paho-agent' connection_id 0 error 'None'
[DEBUG] 2023-06-26 13:05:57.499 AsyncioHelper - On socket unregister write
[DEBUG] 2023-06-26 13:05:57.500 AsyncioHelper - On socket close
[INFO ] 2023-06-26 13:05:57.510 GRPCControlServer - shutdownAgent: reason That's it.
[INFO ] 2023-06-26 13:05:57.512 GRPCControlServer - Server termination done
[INFO ] 2023-06-26 13:05:57.513 GRPCLink - Shutdown gPRC link
[INFO ] 2023-06-26 13:05:57.527 Main - Execution done successfully

Mqtt Client Control output

java -Dmqtt_client_id=Python_Paho_Client -Dmqtt_broker_addr=a3t8vwpkw3sltg-ats.iot.eu-west-1.amazonaws.com -Dmqtt_client_ca_file=creds_aws/rootCA.pem -Dmqtt_client_cert_file=creds_aws/thingCert.crt -Dmqtt_client_key_file=creds_aws/privKey.key -jar target/aws-greengrass-testing-mqtt-client-control.jar 47619 true true
[INFO ] 2023-06-26 13:05:09.129 [main] ExampleControl - Control: port 47619, with TLS, MQTT v5
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
[INFO ] 2023-06-26 13:05:10.415 [main] EngineControlImpl - MQTT client control gRPC server started, listening on 47619
[INFO ] 2023-06-26 13:05:23.348 [grpc-default-executor-0] GRPCDiscoveryServer - RegisterAgent: agentId python-paho-agent
[INFO ] 2023-06-26 13:05:23.372 [grpc-default-executor-0] GRPCDiscoveryServer - DiscoveryClient: agentId python-paho-agent address 127.0.0.1 port 62058
[INFO ] 2023-06-26 13:05:23.377 [grpc-default-executor-0] EngineControlImpl - Created new agent control for python-paho-agent on 127.0.0.1:62058
[INFO ] 2023-06-26 13:05:23.425 [grpc-default-executor-0] ExampleControl - Agent python-paho-agent is connected
[INFO ] 2023-06-26 13:05:23.431 [pool-2-thread-1] AgentTestScenario - Playing test scenario for agent id python-paho-agent
[INFO ] 2023-06-26 13:05:27.135 [pool-2-thread-1] AgentControlImpl - Created connection with id 0 CONNACK 'sessionPresent: false
reasonCode: 0
receiveMaximum: 100
maximumQoS: 1
retainAvailable: true
maximumPacketSize: 149504
wildcardSubscriptionsAvailable: true
subscriptionIdentifiersAvailable: false
sharedSubscriptionsAvailable: true
serverKeepAlive: 60
topicAliasMaximum: 8
'
[INFO ] 2023-06-26 13:05:27.136 [pool-2-thread-1] AgentControlImpl - createMqttConnection: MQTT connectionId 0 created
[INFO ] 2023-06-26 13:05:27.138 [pool-2-thread-1] AgentTestScenario - MQTT connection with id 0 is established
[INFO ] 2023-06-26 13:05:32.149 [pool-2-thread-1] AgentControlImpl - SubscribeMqtt: subscribe on connection 0
[INFO ] 2023-06-26 13:05:32.304 [pool-2-thread-1] AgentTestScenario - Subscribe response: connectionId 0 reason codes [0] reason string ''
[INFO ] 2023-06-26 13:05:37.311 [pool-2-thread-1] AgentControlImpl - PublishMqtt: publishing on connectionId 0 topic test/topic
[INFO ] 2023-06-26 13:05:37.436 [grpc-default-executor-0] GRPCDiscoveryServer - OnReceiveMessage: agentId python-paho-agent connectionId 0 topic test/topic QoS 0
[INFO ] 2023-06-26 13:05:37.438 [grpc-default-executor-0] AgentTestScenario - Message received on agentId python-paho-agent connectionId 0 topic test/topic QoS 0 content <ByteString@3bffc032 size=12 contents="Hello World!">
[INFO ] 2023-06-26 13:05:37.450 [pool-2-thread-1] AgentTestScenario - Published connectionId 0 reason code 0 reason string ''
[INFO ] 2023-06-26 13:05:42.456 [pool-2-thread-1] AgentControlImpl - UnsubscribeMqtt: unsubscribe on connectionId 0
[INFO ] 2023-06-26 13:05:42.465 [pool-2-thread-1] AgentTestScenario - Unsubscribe response: connectionId 0 reason codes [] reason string ''
[INFO ] 2023-06-26 13:05:57.492 [grpc-default-executor-0] GRPCDiscoveryServer - OnMqttDisconnect: agentId python-paho-agent connectionId 0 disconnect 'reasonCode: 0
' error ''
[INFO ] 2023-06-26 13:05:57.493 [grpc-default-executor-0] AgentTestScenario - MQTT disconnected on agentId python-paho-agent connectionId 0 disconnect 'reasonCode: 0
' error ''
[INFO ] 2023-06-26 13:05:57.505 [pool-2-thread-1] AgentControlImpl - closeMqttConnection: MQTT connectionId 0 closed
[INFO ] 2023-06-26 13:05:57.513 [pool-2-thread-1] AgentControlImpl - shutdown request sent successfully
[INFO ] 2023-06-26 13:05:57.517 [grpc-default-executor-0] GRPCDiscoveryServer - UnregisterAgent: agentId python-paho-agent reason Agent shutdown by OTF request 'That's it.'
[INFO ] 2023-06-26 13:05:57.523 [grpc-default-executor-0] ExampleControl - Agent python-paho-agent is disconnected

Any additional information or context required to review the change:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.