- Más nuevo
- Más votos
- Más comentarios
Hello Grzegorz,
Greengrass IPC does not provide any method to know if the MQTT connection to IoT Core is disconnected or not. What you can do is to occasionally send the MQTT message to get Jobs: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-mqtt-api.html#:~:text=GetPendingJobExecutions. This way, your component can receive the job when the connection is eventually available.
Cheers,
Michael
Hi:
Thanks for the detailed use case walkthrough. Can u help me understand the statement that you made - client have on_disconnect function but it's invoked only with executing close function on that connection so it's not the case
? Does that mean you will call the close() function as part of your use case logic? If that is the case, I think we have the reason: Optional[Exception]
as an optional param that you can take advantage. Like when you are calling close() function it is None, and on the other hand you can identify the type of exception of the the MQTT disconnection and conditionally do your own data query logic in the method.
Rafe
Hi No, I will no call it because I don't have reasons to close my connection. I want my connection to be opened all the time and callback on every message on that topic. If on_disconnect function could execute itself on connection interrupted that will be perfect but I don't know how exactly could I implement that because as far as I know it get invoked only after executing close function on connection.
Contenido relevante
- OFICIAL DE AWSActualizada hace 2 años
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace un año
That's a shame tbh. AWS provides a component for shadow state managing and it works brilliantly. Even after reconnecting with a clean session, it's still synchronizing with the cloud on realTime settings and sending message on the local MQTT topic to inform other components, maybe AWS should think about a similar solution for jobs handling? Anyway, in the meantime I developed a workaround solution for this case. For anybody from the future, you can check it here https://github.com/zdb11/Greengrass-Jobs-Handler
Thank you for your link. Knowing the MQTT connection state is something that has been requested before, so I'll see if we can implement that in the future. Greengrass was designed with the idea that components shouldn't really need to care about the state since published messages are queued and sent later when offline, but there are definitely reasons why a component would like to know the true state.