in provisioningHandler.py [0:0]
def core_connect(self):
""" Method used to connect to AWS IoTCore Service. Endpoint collected from iot Handler.
"""
self.logger.info('Connecting with Bootstrap certificate ')
print('Connecting with Bootstrap certificate ')
event_loop_group = io.EventLoopGroup(1)
host_resolver = io.DefaultHostResolver(event_loop_group)
client_bootstrap = io.ClientBootstrap(event_loop_group, host_resolver)
path = self.secure_cert_path.format(unique_id=self.unique_id)
print(self.iot_endpoint)
self.primary_MQTTClient = mqtt_connection_builder.mtls_from_path(
endpoint=self.iot_endpoint,
cert_filepath="{}/{}".format(path, self.claim_cert),
pri_key_filepath="{}/{}".format(path, self.secure_key),
client_bootstrap=client_bootstrap,
ca_filepath="{}/{}".format(self.root_cert_path, self.root_cert),
on_connection_interrupted=self.on_connection_interrupted,
on_connection_resumed=self.on_connection_resumed,
client_id=self.unique_id,
clean_session=False,
keep_alive_secs=6)
print("Connecting to {} with client ID '{}'...".format(self.iot_endpoint, self.unique_id))
connect_future = self.primary_MQTTClient.connect()
# Future.result() waits until a result is available
connect_future.result()
print("Connected!")