aws-iot-greengrass-for-beginners/alert/main.py [134:162]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                        pri_key_filepath=private_key_path,
                        client_bootstrap=client_bootstrap,
                        ca_bytes=gg_group.certificate_authorities[0].encode(
                            'utf-8'),
                        on_connection_interrupted=on_connection_interupted,
                        on_connection_resumed=on_connection_resumed,
                        client_id=device_name,
                        clean_session=False,
                        keep_alive_secs=6)

                    connect_future = connection.connect()
                    connect_future.result()
                    print('Connected!')

                    return connection

                except Exception as e:
                    print('Connection failed with exception {}'.format(e))
                    continue

    sys.exit('All connection attempts failed')


def on_connection_interupted(connection, error, **kwargs):
    logger.info('connection interrupted with error {}' % error)


# Callback when an interrupted connection is re-established.
def on_connection_resumed(connection, return_code, session_present, **kwargs):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



aws-iot-greengrass-for-beginners/sensor/main.py [135:162]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                        pri_key_filepath=private_key_path,
                        client_bootstrap=client_bootstrap,
                        ca_bytes=gg_group.certificate_authorities[0].encode(
                            'utf-8'),
                        on_connection_interrupted=on_connection_interupted,
                        on_connection_resumed=on_connection_resumed,
                        client_id=device_name,
                        clean_session=False,
                        keep_alive_secs=6)

                    connect_future = connection.connect()
                    connect_future.result()
                    print('Connected!')

                    return connection

                except Exception as e:
                    print('Connection failed with exception {}'.format(e))
                    continue

    sys.exit('All connection attempts failed')


def on_connection_interupted(connection, error, **kwargs):
    logger.info('connection interrupted with error {}' % error)


def on_connection_resumed(connection, return_code, session_present, **kwargs):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



