You can check which IP your GGAD uses to connect to Greengrass Core by checking the discovery logs. IP change of Greengrass Core might impact the connection, because GGAD does not have the information that GGC runs on the same host.
I suggest you remove the discovery logic in your GGAD, and instead hardcode the GGC IP to be localhost during connection here https://github.com/aws/aws-iot-device-sdk-python/blob/master/samples/greengrass/basicDiscovery.py#L152
Let me know if this works for you.
Thank you very much for your answer.
I removed the discovery logic and hardcoded 127.0.0.1 to be the GGC IP in my Python Script.
However it seems that I keep getting disconnected from Greengrass everytime my public IP is changing, which makes me think that there is another issue between the GGC and the Cloud... but I did not find it yet.
Alternatively, I implemented a simple script that monitors my public IP and restarts the GG daemon when it changes. That prevents permanent disconnections, but I lose as expected the cached messages.
The problem you're running into is the certificates used between the GGAD and the GGC will rotate whenever the IP changes. Even if you only connect locally. You can verify that by looking at the logs to see the certificates rotate.
I've added your comments to our feature request list.
Is there any specific reason you are using a GGAD to communicate with Greengrass on the same machine?
If you are running the script on the same machine as Greengrass, you could implement the functionality in a Lambda function instead of using GGAD. This would be a much simpler solution.
Thanks a lot for both these answers.
If I understand correctly, with my current architecture (GGAD + GGC), it is impossible to solve the issue with the current Greengrass version because of this certificate rotation.
We used a GGAD to communicate with the GGC on the same machine mainly for historical reasons : we updated our system from working directly with AWS IoT Core to AWS Greengrass so we modified our pre-existing "data-producer" Python script to connect to Greengrass (using the basicDiscovery example routines) instead of directly connecting to AWS IoT. The idea of using directly a Lambda on the core seems interesting. I'll investigate if that modification is possible with our current architecture and system components / sensors and I'll keep that in mind for future architectures.
Greengrass - best way to handle setting a topic based on the core device?Accepted Answerasked 3 months ago
com.aws.greengrass.mqttclient.AwsIotMqttClient: Unable to connect to AWS IoT CoreAccepted Answerasked a year ago
Can Greengrass use a Lambda in the Core if needed?asked a year ago
Greengrass Core Local Connectivity Informationasked 4 years ago
Do machine learning models run within an AWS IoT Greengrass group or on an AWS IoT Greengrass core?Accepted AnswerEXPERTasked 2 years ago
Greengrass on Ubuntu Core (Classic mode)asked 3 years ago
GG Core IP Change cuts connexion to Cloudasked 3 years ago
How to change the greengrass v2 config on a core deviceAccepted Answerasked 9 months ago
Ghost Lambdas responding to IoT Cloud subscriptionsasked 3 years ago